From 7dca3d745196921cf8ebef33342b8cfa7027f3e1 Mon Sep 17 00:00:00 2001 From: Manos Liolios Date: Thu, 19 Feb 2026 13:16:52 +0200 Subject: [PATCH 1/3] Rename to --- README.md | 24 +-- .../pas/sources/{vault.move => chest.move} | 116 +++++------ packages/pas/sources/keys.move | 6 +- packages/pas/sources/namespace.move | 18 +- .../pas/sources/requests/clawback_funds.move | 12 +- .../pas/sources/requests/transfer_funds.move | 30 +-- .../pas/sources/requests/unlock_funds.move | 14 +- ..._auth_tests.move => chest_auth_tests.move} | 58 +++--- packages/pas/tests/clawback_tests.move | 24 +-- packages/pas/tests/e2e.move | 192 +++++++++--------- packages/pas/tests/rule_setup_tests.move | 12 +- packages/pas/tests/versioning_tests.move | 32 +-- sdk/example-app/src/extension-example.ts | 24 +-- sdk/pas/src/client.ts | 30 +-- .../src/contracts/pas/{vault.ts => chest.ts} | 78 +++---- sdk/pas/src/contracts/pas/clawback_funds.ts | 16 +- sdk/pas/src/contracts/pas/keys.ts | 2 +- sdk/pas/src/contracts/pas/namespace.ts | 22 +- sdk/pas/src/contracts/pas/transfer_funds.ts | 32 +-- sdk/pas/src/contracts/pas/unlock_funds.ts | 18 +- sdk/pas/src/derivation.ts | 22 +- sdk/pas/src/intents.ts | 186 ++++++++--------- sdk/pas/src/resolution.ts | 28 +-- sdk/pas/test/e2e/e2e.isolated.test.ts | 172 ++++++++-------- sdk/pas/test/e2e/e2e.shared.test.ts | 26 +-- sdk/pas/test/e2e/setup.ts | 6 +- sdk/pas/test/unit/derivation.test.ts | 36 ++-- 27 files changed, 618 insertions(+), 618 deletions(-) rename packages/pas/sources/{vault.move => chest.move} (57%) rename packages/pas/tests/{vault_auth_tests.move => chest_auth_tests.move} (51%) rename sdk/pas/src/contracts/pas/{vault.ts => chest.ts} (86%) diff --git a/README.md b/README.md index cfdda38..0ceb0a0 100644 --- a/README.md +++ b/README.md @@ -8,35 +8,35 @@ The P-Assets Standard is a framework for issuing and managing permissioned balan ## TLDR -1. Each address has a single vault (derived address, with easy discoverability). Objects can own vaults as well. This enables with account abstractions / defi protocols implementations -2. Vault uses address (object) balances, so RPCs work out of the box (wallet just treats the vault address like a normal one). Wallets/explorers needs to query for the derived vault address to get balances. -3. Balances can only move from vault to vault (either by safe vault-to-vault deposits, or deriving the recipient with `unsafe_` calls) +1. Each address has a single chest (derived address, with easy discoverability). Objects can own chests as well. This enables with account abstractions / defi protocols implementations +2. Chest uses address (object) balances, so RPCs work out of the box (wallet just treats the chest address like a normal one). Wallets/explorers needs to query for the derived chest address to get balances. +3. Balances can only move from chest to chest (either by safe chest-to-chest deposits, or deriving the recipient with `unsafe_` calls) 4. When a transfer is initiated, a `TransferFunds` is issued, which can be resolved, on the PTB layer, calling the `Command` that is specified by the issuer. The issuer can "approve" it in their own package by presenting a witness. Any custom logic (KYC, checks) can be implemented there. -5. Clawback is available (vaults are shared and a clawback can be initiated using the issuer's witness). +5. Clawback is available (chests are shared and a clawback can be initiated using the issuer's witness). -(To be added: Issuers can attach "metadata" to user's Vaults (such as `KYC` stamps or AML stamps they issue), which they can then check on their transfer functions to restrict movement. Since vaults are shared, issuers can revoke these stamps at any moment). +(To be added: Issuers can attach "metadata" to user's Chests (such as `KYC` stamps or AML stamps they issue), which they can then check on their transfer functions to restrict movement. Since chests are shared, issuers can revoke these stamps at any moment). ## Key Features -- **Permissioned Transfers**: All transfers must go through vaults and be approved by custom transfer rules -- **Vault-Based Architecture**: Tokens can only be held in vaults, with automatic balance tracking +- **Permissioned Transfers**: All transfers must go through chests and be approved by custom transfer rules +- **Chest-Based Architecture**: Tokens can only be held in chests, with automatic balance tracking - **Flexible Rules System**: Each token type has associated rules that govern transfers with jurisdiction-specific compliance - **Optional Clawback**: Regulatory compliance feature that allows token recovery when legally required ## How It Works 1. **Setup**: Registry is created as a shared object, token issuers register their tokens with rules -2. **Vault Creation**: Vaults are derived for each address that needs to hold tokens -3. **Transfers**: Initiated from source vault, creating a transfer request that must be resolved by the rule +2. **Chest Creation**: Chests are derived for each address that needs to hold tokens +3. **Transfers**: Initiated from source chest, creating a transfer request that must be resolved by the rule 4. **Resolution**: Token-specific smart contracts validate and approve transfers based on compliance rules ## Wallet & SDK Integration ### Simple Discovery The standard uses derived objects for predictable addresses: -- **Single vault per user** which holds the balances of the user -- **No indexing required** - vault and rule addresses are deterministically computable -- **One query** to see all user balances via dynamic fields on their vault +- **Single chest per user** which holds the balances of the user +- **No indexing required** - chest and rule addresses are deterministically computable +- **One query** to see all user balances via dynamic fields on their chest ### Easy Resolution diff --git a/packages/pas/sources/vault.move b/packages/pas/sources/chest.move similarity index 57% rename from packages/pas/sources/vault.move rename to packages/pas/sources/chest.move index 64f6d22..28bc9d1 100644 --- a/packages/pas/sources/vault.move +++ b/packages/pas/sources/chest.move @@ -1,5 +1,5 @@ -/// Vault logic -module pas::vault; +/// Chest logic +module pas::chest; use pas::{ clawback_funds::{Self, ClawbackFunds}, @@ -14,20 +14,20 @@ use sui::{balance::{Self, Balance}, derived_object}; use fun balance::withdraw_funds_from_object as UID.withdraw_funds_from_object; #[error(code = 1)] -const ENotOwner: vector = b"The owner is not valid for the vault."; +const ENotOwner: vector = b"The owner is not valid for the chest."; #[error(code = 2)] -const EVaultAlreadyExists: vector = b"The vault already exists."; - -/// There is only one Vault per address (guaranteed by derived objects). -/// - Balances can only be transferred from Vault A to Vault B. -/// - Vaults are shared by default. -/// - Vaults creation is permission-less -/// - A `UID` (object) can also own a vault -public struct Vault has key { +const EChestAlreadyExists: vector = b"The chest already exists."; + +/// There is only one Chest per address (guaranteed by derived objects). +/// - Balances can only be transferred from Chest A to Chest B. +/// - Chests are shared by default. +/// - Chests creation is permission-less +/// - A `UID` (object) can also own a chest +public struct Chest has key { id: UID, - /// The owner of the vault (address or object) + /// The owner of the chest (address or object) owner: address, - /// The ID of the namespace that created this vault. + /// The ID of the namespace that created this chest. /// There's ONLY ONE namespace in the system, but this helps us avoid having /// `&Namespace` inputs in all functions that need to derive the IDs. namespace_id: ID, @@ -39,28 +39,28 @@ public struct Vault has key { /// `UID` and `ctx.sender()` (keeping a single API for both). public struct Auth(address) has drop; -/// Create a new vault for `owner`. This is a permission-less action. -public fun create(namespace: &mut Namespace, owner: address): Vault { - assert!(!namespace.vault_exists(owner), EVaultAlreadyExists); +/// Create a new chest for `owner`. This is a permission-less action. +public fun create(namespace: &mut Namespace, owner: address): Chest { + assert!(!namespace.chest_exists(owner), EChestAlreadyExists); let versioning = namespace.versioning(); versioning.assert_is_valid_version(); - Vault { - id: derived_object::claim(namespace.uid_mut(), keys::vault_key(owner)), + Chest { + id: derived_object::claim(namespace.uid_mut(), keys::chest_key(owner)), owner, namespace_id: object::id(namespace), versioning, } } -/// The only way to finalize the TX is by sharing the vault. -/// All vaults are shared by default. -public fun share(vault: Vault) { - transfer::share_object(vault); +/// The only way to finalize the TX is by sharing the chest. +/// All chests are shared by default. +public fun share(chest: Chest) { + transfer::share_object(chest); } -/// Create and share a vault in a single step. +/// Create and share a chest in a single step. public fun create_and_share(namespace: &mut Namespace, owner: address) { create(namespace, owner).share() } @@ -69,25 +69,25 @@ public fun create_and_share(namespace: &mut Namespace, owner: address) { /// This is useful for assets that are not managed by a Rule within the system, or /// if there's a special case where an issuer allows balances to flow out of the system. public fun unlock_funds( - vault: &mut Vault, + chest: &mut Chest, auth: &Auth, amount: u64, _ctx: &mut TxContext, ): Request> { - auth.assert_is_valid_for_vault!(vault); - vault.versioning.assert_is_valid_version(); - unlock_funds::new(vault.owner, vault.id.to_inner(), vault.withdraw(amount)) + auth.assert_is_valid_for_chest!(chest); + chest.versioning.assert_is_valid_version(); + unlock_funds::new(chest.owner, chest.id.to_inner(), chest.withdraw(amount)) } -/// Initiate a transfer from vault A to vault B. +/// Initiate a transfer from chest A to chest B. public fun transfer_funds( - from: &mut Vault, + from: &mut Chest, auth: &Auth, - to: &Vault, + to: &Chest, amount: u64, _ctx: &mut TxContext, ): Request> { - auth.assert_is_valid_for_vault!(from); + auth.assert_is_valid_for_chest!(from); from.versioning.assert_is_valid_version(); from.internal_transfer_funds(to.owner, amount) } @@ -97,7 +97,7 @@ public fun transfer_funds( /// /// This can only ever finalize if clawback is enabled in the rule. public fun clawback_funds( - from: &mut Vault, + from: &mut Chest, amount: u64, _ctx: &mut TxContext, ): Request> { @@ -105,19 +105,19 @@ public fun clawback_funds( clawback_funds::new(from.owner, from.id.to_inner(), from.withdraw(amount)) } -/// Transfer `amount` from vault to an address. This unlocks transfers to a vault before it has been created. +/// Transfer `amount` from chest to an address. This unlocks transfers to a chest before it has been created. /// /// It's marked as `unsafe_` as it's easy to accidentally pick the wrong recipient address. public fun unsafe_transfer_funds( - from: &mut Vault, + from: &mut Chest, auth: &Auth, - // Recipients should always be the wallet or object address, not the vault ID. + // Recipients should always be the wallet or object address, not the chest ID. // It's recommended to use `transfer` instead for safer transfers. recipient_address: address, amount: u64, _ctx: &mut TxContext, ): Request> { - auth.assert_is_valid_for_vault!(from); + auth.assert_is_valid_for_chest!(from); from.versioning.assert_is_valid_version(); from.internal_transfer_funds(recipient_address, amount) } @@ -127,58 +127,58 @@ public fun new_auth(ctx: &TxContext): Auth { Auth(ctx.sender()) } -/// Generate an ownership proof from a `UID` object, to allow objects to own vaults. +/// Generate an ownership proof from a `UID` object, to allow objects to own chests. public fun new_auth_as_object(uid: &mut UID): Auth { Auth(uid.to_inner().to_address()) } -public fun owner(vault: &Vault): address { - vault.owner +public fun owner(chest: &Chest): address { + chest.owner } -public fun deposit_funds(vault: &Vault, balance: Balance) { - vault.versioning.assert_is_valid_version(); - balance::send_funds(balance, object::id(vault).to_address()); +public fun deposit_funds(chest: &Chest, balance: Balance) { + chest.versioning.assert_is_valid_version(); + balance::send_funds(balance, object::id(chest).to_address()); } /// Permission-less operation to bring versioning up-to-date with the namespace. -public fun sync_versioning(vault: &mut Vault, namespace: &Namespace) { - vault.versioning = namespace.versioning(); +public fun sync_versioning(chest: &mut Chest, namespace: &Namespace) { + chest.versioning = namespace.versioning(); } -public(package) fun withdraw(vault: &mut Vault, amount: u64): Balance { - vault.versioning.assert_is_valid_version(); - balance::redeem_funds(vault.id.withdraw_funds_from_object(amount)) +public(package) fun withdraw(chest: &mut Chest, amount: u64): Balance { + chest.versioning.assert_is_valid_version(); + balance::redeem_funds(chest.id.withdraw_funds_from_object(amount)) } -public(package) fun versioning(vault: &Vault): Versioning { - vault.versioning +public(package) fun versioning(chest: &Chest): Versioning { + chest.versioning } -/// Verify that the ownership proof matches the vaults owner. -macro fun assert_is_valid_for_vault($proof: &Auth, $vault: &Vault) { +/// Verify that the ownership proof matches the chests owner. +macro fun assert_is_valid_for_chest($proof: &Auth, $chest: &Chest) { let proof = $proof; - let vault = $vault; - assert!(&proof.0 == &vault.owner, ENotOwner); + let chest = $chest; + assert!(&proof.0 == &chest.owner, ENotOwner); } -/// The internal implementation for transferring `amount` from Vault towards another address. +/// The internal implementation for transferring `amount` from Chest towards another address. /// -/// INTERNAL WARNING: Callers must verify that `to` is the user address, NOT the vault address. +/// INTERNAL WARNING: Callers must verify that `to` is the user address, NOT the chest address. /// Failure to do so can cause assets to move out of the closed loop, breaking the system assurances fun internal_transfer_funds( - from: &mut Vault, + from: &mut Chest, to: address, amount: u64, ): Request> { let balance = from.withdraw(amount); - let recipient_vault_id = namespace::vault_address_from_id(from.namespace_id, to); + let recipient_chest_id = namespace::chest_address_from_id(from.namespace_id, to); transfer_funds::new( from.owner, to, from.id.to_inner(), - recipient_vault_id.to_id(), + recipient_chest_id.to_id(), balance, ) } diff --git a/packages/pas/sources/keys.move b/packages/pas/sources/keys.move index 9bb9d63..7f2ea7e 100644 --- a/packages/pas/sources/keys.move +++ b/packages/pas/sources/keys.move @@ -6,8 +6,8 @@ use sui::vec_set::{Self, VecSet}; /// Key for deriving `Rule` from the namespace public struct RuleKey() has copy, drop, store; -/// Key for deriving `Vault` from the namespace -public struct VaultKey(address) has copy, drop, store; +/// Key for deriving `Chest` from the namespace +public struct ChestKey(address) has copy, drop, store; /// Key for deriving `Templates` from the namespace public struct TemplateKey() has copy, drop, store; @@ -15,7 +15,7 @@ public struct TemplateKey() has copy, drop, store; /// WARNING: these should only be used internally. public(package) fun rule_key(): RuleKey { RuleKey() } -public(package) fun vault_key(owner: address): VaultKey { VaultKey(owner) } +public(package) fun chest_key(owner: address): ChestKey { ChestKey(owner) } public(package) fun template_key(): TemplateKey { TemplateKey() } diff --git a/packages/pas/sources/namespace.move b/packages/pas/sources/namespace.move index 35087d8..7c6dffe 100644 --- a/packages/pas/sources/namespace.move +++ b/packages/pas/sources/namespace.move @@ -1,7 +1,7 @@ /// The Namespace module. /// /// Namespace is responsible for creating objects that are easy to query & find: -/// 1. Vaults +/// 1. Chests /// 2. Rules /// ... any other module we might add in the future module pas::namespace; @@ -19,7 +19,7 @@ const EUpgradeCapPackageMismatch: vector = const EUpgradeCapNotSet: vector = b"The upgrade cap is not set for this namespace, making it unusable."; -/// The namespace is only used for address derivation of vaults, rules, etc. +/// The namespace is only used for address derivation of chests, rules, etc. /// /// Namespace is a singleton -- there's one global version for it. public struct Namespace has key { @@ -79,17 +79,17 @@ public fun rule_address(namespace: &Namespace): address { derived_object::derive_address(namespace.id.to_inner(), keys::rule_key()) } -public fun vault_exists(namespace: &Namespace, owner: address): bool { - derived_object::exists(&namespace.id, keys::vault_key(owner)) +public fun chest_exists(namespace: &Namespace, owner: address): bool { + derived_object::exists(&namespace.id, keys::chest_key(owner)) } -public fun vault_address(namespace: &Namespace, owner: address): address { - derived_object::derive_address(namespace.id.to_inner(), keys::vault_key(owner)) +public fun chest_address(namespace: &Namespace, owner: address): address { + derived_object::derive_address(namespace.id.to_inner(), keys::chest_key(owner)) } -// Given the name space ID, calculate the vault address. -public(package) fun vault_address_from_id(namespace_id: ID, owner: address): address { - derived_object::derive_address(namespace_id, keys::vault_key(owner)) +// Given the name space ID, calculate the chest address. +public(package) fun chest_address_from_id(namespace_id: ID, owner: address): address { + derived_object::derive_address(namespace_id, keys::chest_key(owner)) } public(package) fun versioning(namespace: &Namespace): Versioning { diff --git a/packages/pas/sources/requests/clawback_funds.move b/packages/pas/sources/requests/clawback_funds.move index 2d85613..d4f58af 100644 --- a/packages/pas/sources/requests/clawback_funds.move +++ b/packages/pas/sources/requests/clawback_funds.move @@ -8,28 +8,28 @@ const EClawbackNotAllowed: vector = b"Attempted to clawback tokens when clawback is not enabled for this rule."; public struct ClawbackFunds { - /// `owner` is the wallet OR object address, NOT the vault address + /// `owner` is the wallet OR object address, NOT the chest address owner: address, - /// The ID of the vault the funds are coming from - vault_id: ID, + /// The ID of the chest the funds are coming from + chest_id: ID, /// The balance that is being clawed back. balance: Balance, } public fun owner(request: &ClawbackFunds): address { request.owner } -public fun vault_id(request: &ClawbackFunds): ID { request.vault_id } +public fun chest_id(request: &ClawbackFunds): ID { request.chest_id } public fun amount(request: &ClawbackFunds): u64 { request.balance.value() } public(package) fun new( owner: address, - vault_id: ID, + chest_id: ID, balance: Balance, ): Request> { request::new(ClawbackFunds { owner, - vault_id, + chest_id, balance, }) } diff --git a/packages/pas/sources/requests/transfer_funds.move b/packages/pas/sources/requests/transfer_funds.move index 40fed98..9d6fe85 100644 --- a/packages/pas/sources/requests/transfer_funds.move +++ b/packages/pas/sources/requests/transfer_funds.move @@ -18,14 +18,14 @@ use sui::balance::{Self, Balance}; /// - Handle dividends/distributions /// - Implement any jurisdiction-specific rules public struct TransferFunds { - /// `sender` is the wallet OR object address, NOT the vault address + /// `sender` is the wallet OR object address, NOT the chest address sender: address, - /// `recipient` is the wallet OR object address, NOT the vault address + /// `recipient` is the wallet OR object address, NOT the chest address recipient: address, - /// The ID of the vault the funds are coming from - sender_vault_id: ID, - /// The ID of the vault the funds are going to - recipient_vault_id: ID, + /// The ID of the chest the funds are coming from + sender_chest_id: ID, + /// The ID of the chest the funds are going to + recipient_chest_id: ID, /// The amount being transferred (original) amount: u64, /// The actual balance being transferred @@ -36,10 +36,10 @@ public fun sender(request: &TransferFunds): address { request.sender } public fun recipient(request: &TransferFunds): address { request.recipient } -public fun sender_vault_id(request: &TransferFunds): ID { request.sender_vault_id } +public fun sender_chest_id(request: &TransferFunds): ID { request.sender_chest_id } -public fun recipient_vault_id(request: &TransferFunds): ID { - request.recipient_vault_id +public fun recipient_chest_id(request: &TransferFunds): ID { + request.recipient_chest_id } public fun amount(request: &TransferFunds): u64 { request.amount } @@ -47,15 +47,15 @@ public fun amount(request: &TransferFunds): u64 { request.amount } public(package) fun new( sender: address, recipient: address, - sender_vault_id: ID, - recipient_vault_id: ID, + sender_chest_id: ID, + recipient_chest_id: ID, balance: Balance, ): Request> { request::new(TransferFunds { sender, recipient, - sender_vault_id, - recipient_vault_id, + sender_chest_id, + recipient_chest_id, amount: balance.value(), balance, }) @@ -67,6 +67,6 @@ public fun resolve(request: Request>, rule: &Rule) { rule.assert_is_fund_management_enabled(); let data = request.resolve(rule.required_approvals(transfer_funds_action())); - let TransferFunds { balance, recipient_vault_id, .. } = data; - balance::send_funds(balance, recipient_vault_id.to_address()); + let TransferFunds { balance, recipient_chest_id, .. } = data; + balance::send_funds(balance, recipient_chest_id.to_address()); } diff --git a/packages/pas/sources/requests/unlock_funds.move b/packages/pas/sources/requests/unlock_funds.move index 1fba14f..145b026 100644 --- a/packages/pas/sources/requests/unlock_funds.move +++ b/packages/pas/sources/requests/unlock_funds.move @@ -14,10 +14,10 @@ const ECannotResolveManagedAssets: vector = /// by calling `rule::resolve_unlock_funds` /// 2. If the asset is not permissioned, it can be resolved by any address by calling `unlock_funds::resolve_unrestricted` public struct UnlockFunds { - /// `from` is the wallet OR object address, NOT the vault address + /// `from` is the wallet OR object address, NOT the chest address owner: address, - /// The ID of the vault the funds are coming from - vault_id: ID, + /// The ID of the chest the funds are coming from + chest_id: ID, /// The amount being transferred (initial amount) amount: u64, /// The actual balance being transferred @@ -26,7 +26,7 @@ public struct UnlockFunds { public fun owner(request: &UnlockFunds): address { request.owner } -public fun vault_id(request: &UnlockFunds): ID { request.vault_id } +public fun chest_id(request: &UnlockFunds): ID { request.chest_id } public fun amount(request: &UnlockFunds): u64 { request.amount } @@ -34,7 +34,7 @@ public fun amount(request: &UnlockFunds): u64 { request.amount } /// If a `Rule` exists, they can only be resolved from within the system. /// /// For example, `SUI` will never be a managed asset, so the owner needs to be able -/// to withdraw if anyone transfers some to their vault. +/// to withdraw if anyone transfers some to their chest. public fun resolve_unrestricted( request: Request>, namespace: &Namespace, @@ -48,12 +48,12 @@ public fun resolve_unrestricted( public(package) fun new( owner: address, - vault_id: ID, + chest_id: ID, balance: Balance, ): Request> { request::new(UnlockFunds { owner, - vault_id, + chest_id, amount: balance.value(), balance, }) diff --git a/packages/pas/tests/vault_auth_tests.move b/packages/pas/tests/chest_auth_tests.move similarity index 51% rename from packages/pas/tests/vault_auth_tests.move rename to packages/pas/tests/chest_auth_tests.move index 4664b97..e9c51a7 100644 --- a/packages/pas/tests/vault_auth_tests.move +++ b/packages/pas/tests/chest_auth_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] -module pas::vault_auth_tests; +module pas::chest_auth_tests; -use pas::{e2e::{test_tx, A}, vault::{Self, Vault}}; +use pas::{e2e::{test_tx, A}, chest::{Self, Chest}}; use std::unit_test::{assert_eq, destroy}; use sui::test_scenario::return_shared; @@ -15,18 +15,18 @@ fun authenticate_with_uid() { let mut uid = object::new(scenario.ctx()); let uid_address = uid.to_inner().to_address(); - vault::create_and_share(namespace, uid_address); + chest::create_and_share(namespace, uid_address); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared(); + let mut chest = scenario.take_shared(); - assert_eq!(vault.owner(), uid_address); - assert_eq!(object::id(&vault).to_address(), namespace.vault_address(uid_address)); + assert_eq!(chest.owner(), uid_address); + assert_eq!(object::id(&chest).to_address(), namespace.chest_address(uid_address)); - let auth = vault::new_auth_as_object(&mut uid); + let auth = chest::new_auth_as_object(&mut uid); - let transfer_request = vault.unsafe_transfer_funds( + let transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -36,39 +36,39 @@ fun authenticate_with_uid() { assert_eq!(transfer_request.data().sender(), uid_address); assert_eq!(transfer_request.data().recipient(), @0x2); assert_eq!( - transfer_request.data().sender_vault_id(), - namespace.vault_address(uid_address).to_id(), + transfer_request.data().sender_chest_id(), + namespace.chest_address(uid_address).to_id(), ); assert_eq!( - transfer_request.data().recipient_vault_id(), - namespace.vault_address(@0x2).to_id(), + transfer_request.data().recipient_chest_id(), + namespace.chest_address(@0x2).to_id(), ); assert_eq!(transfer_request.data().amount(), 50); destroy(transfer_request); - return_shared(vault); + return_shared(chest); uid.delete(); }); } -#[test, expected_failure(abort_code = ::pas::vault::ENotOwner)] -fun try_to_auth_to_another_owners_vault() { +#[test, expected_failure(abort_code = ::pas::chest::ENotOwner)] +fun try_to_auth_to_another_owners_chest() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - vault::create_and_share(namespace, @0x1); + chest::create_and_share(namespace, @0x1); scenario.next_tx(@0x2); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let auth = vault::new_auth(scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); - let _transfer_request = vault.unsafe_transfer_funds( + let _transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -79,17 +79,17 @@ fun try_to_auth_to_another_owners_vault() { }); } -#[test, expected_failure(abort_code = ::pas::vault::ENotOwner)] -fun try_to_auth_to_another_uid_vault() { +#[test, expected_failure(abort_code = ::pas::chest::ENotOwner)] +fun try_to_auth_to_another_uid_chest() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); + let mut chest = chest::create(namespace, @0x1); let mut uid = object::new(scenario.ctx()); - let auth = vault::new_auth_as_object(&mut uid); + let auth = chest::new_auth_as_object(&mut uid); - let transfer_request = vault.unlock_funds( + let transfer_request = chest.unlock_funds( &auth, 50, scenario.ctx(), @@ -99,12 +99,12 @@ fun try_to_auth_to_another_uid_vault() { }); } -#[test, expected_failure(abort_code = ::pas::vault::EVaultAlreadyExists)] -fun try_to_create_vault_with_same_owner() { +#[test, expected_failure(abort_code = ::pas::chest::EChestAlreadyExists)] +fun try_to_create_chest_with_same_owner() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - vault::create_and_share(namespace, @0x1); - vault::create_and_share(namespace, @0x1); + chest::create_and_share(namespace, @0x1); + chest::create_and_share(namespace, @0x1); abort }); } diff --git a/packages/pas/tests/clawback_tests.move b/packages/pas/tests/clawback_tests.move index bf1aade..df7bdf0 100644 --- a/packages/pas/tests/clawback_tests.move +++ b/packages/pas/tests/clawback_tests.move @@ -5,7 +5,7 @@ use pas::{ clawback_funds, e2e::{test_tx, a_witness, A, b_witness, B, AWitness}, rule::RuleCap, - vault + chest }; use std::{type_name, unit_test::assert_eq}; use sui::balance; @@ -14,13 +14,13 @@ use sui::balance; fun clawback_managed_assets() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let mut clawback_request = vault.clawback_funds(50, scenario.ctx()); + let mut clawback_request = chest.clawback_funds(50, scenario.ctx()); assert_eq!(clawback_request.data().amount(), 50); assert_eq!(clawback_request.data().owner(), @0x1); - assert_eq!(clawback_request.data().vault_id(), namespace.vault_address(@0x1).to_id()); + assert_eq!(clawback_request.data().chest_id(), namespace.chest_address(@0x1).to_id()); clawback_request.approve(a_witness()); @@ -31,7 +31,7 @@ fun clawback_managed_assets() { assert_eq!(balance.value(), 50); - vault.share(); + chest.share(); balance.send_funds(@0x10); }); @@ -45,10 +45,10 @@ fun try_to_clawback_when_clawback_stamp_is_not_set() { let rule_cap = scenario.take_from_sender>(); managed_rule.remove_action_approval(&rule_cap, "clawback_funds"); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let mut clawback_request = vault.clawback_funds(50, scenario.ctx()); + let mut clawback_request = chest.clawback_funds(50, scenario.ctx()); clawback_request.approve(a_witness()); let balance = clawback_funds::resolve(clawback_request, managed_rule); @@ -60,10 +60,10 @@ fun try_to_clawback_when_clawback_stamp_is_not_set() { fun try_to_clawback_unmanaged_assets() { test_tx!(@0x1, |namespace, _managed_rule, unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let mut clawback_request = vault.clawback_funds(50, scenario.ctx()); + let mut clawback_request = chest.clawback_funds(50, scenario.ctx()); clawback_request.approve(b_witness()); let _balance = clawback_funds::resolve(clawback_request, unmanaged_rule); diff --git a/packages/pas/tests/e2e.move b/packages/pas/tests/e2e.move index 301e604..1f952de 100644 --- a/packages/pas/tests/e2e.move +++ b/packages/pas/tests/e2e.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::e2e; -use pas::{rule::{Self, RuleCap}, transfer_funds, unlock_funds, vault::{Self, Vault}}; +use pas::{rule::{Self, RuleCap}, transfer_funds, unlock_funds, chest::{Self, Chest}}; use std::{type_name, unit_test::{assert_eq, destroy}}; use sui::{balance::{Self, send_funds}, sui::SUI, test_scenario::return_shared, vec_set}; @@ -19,33 +19,33 @@ fun e2e() { let namespace_id = object::id(namespace); - // create vaults of 0x1 and 0x2 - let vault = vault::create(namespace, @0x1); - let another_vault = vault::create(namespace, @0x2); + // create chests of 0x1 and 0x2 + let chest = chest::create(namespace, @0x1); + let another_chest = chest::create(namespace, @0x2); // transfer some funds to both 0x1 and 0x2 - vault.deposit_funds(balance::create_for_testing(100)); + chest.deposit_funds(balance::create_for_testing(100)); - balance::create_for_testing(50).send_funds(namespace.vault_address(@0x2)); + balance::create_for_testing(50).send_funds(namespace.chest_address(@0x2)); - vault.share(); - another_vault.share(); + chest.share(); + another_chest.share(); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let another_vault = scenario.take_shared_by_id(namespace - .vault_address(@0x2) + let another_chest = scenario.take_shared_by_id(namespace + .chest_address(@0x2) .to_id()); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.transfer_funds( &auth, - &another_vault, + &another_chest, 50, scenario.ctx(), ); @@ -53,8 +53,8 @@ fun e2e() { transfer_request.approve(AWitness()); transfer_funds::resolve(transfer_request, managed_rule); - return_shared(vault); - return_shared(another_vault); + return_shared(chest); + return_shared(another_chest); }); } @@ -63,18 +63,18 @@ fun try_to_approve_transfer_with_invalid_witness() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { let namespace_id = object::id(namespace); scenario.next_tx(@0x1); - vault::create_and_share(namespace, @0x1); + chest::create_and_share(namespace, @0x1); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.unsafe_transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -92,21 +92,21 @@ fun try_to_approve_transfer_with_invalid_witness() { #[test] fun test_address_and_derivation_matches() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { - let user_one_vault_id = namespace.vault_address(@0x1).to_id(); - let user_two_vault_id = namespace.vault_address(@0x2).to_id(); + let user_one_chest_id = namespace.chest_address(@0x1).to_id(); + let user_two_chest_id = namespace.chest_address(@0x2).to_id(); scenario.next_tx(@0x1); - vault::create_and_share(namespace, @0x1); - vault::create_and_share(namespace, @0x2); + chest::create_and_share(namespace, @0x1); + chest::create_and_share(namespace, @0x2); scenario.next_tx(@0x1); - let mut user_one_vault = scenario.take_shared_by_id(user_one_vault_id); - let user_two_vault = scenario.take_shared_by_id(user_two_vault_id); + let mut user_one_chest = scenario.take_shared_by_id(user_one_chest_id); + let user_two_chest = scenario.take_shared_by_id(user_two_chest_id); - let auth = vault::new_auth(scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); - let transfer_request = user_one_vault.unsafe_transfer_funds( + let transfer_request = user_one_chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -115,28 +115,28 @@ fun test_address_and_derivation_matches() { assert_eq!(transfer_request.data().sender(), @0x1); assert_eq!(transfer_request.data().recipient(), @0x2); - assert_eq!(transfer_request.data().sender_vault_id(), user_one_vault_id); - assert_eq!(transfer_request.data().recipient_vault_id(), user_two_vault_id); + assert_eq!(transfer_request.data().sender_chest_id(), user_one_chest_id); + assert_eq!(transfer_request.data().recipient_chest_id(), user_two_chest_id); assert_eq!(transfer_request.data().amount(), 50); // Both scenarios must calculate the from/to equivalent. - let safe_request = user_one_vault.transfer_funds( + let safe_request = user_one_chest.transfer_funds( &auth, - &user_two_vault, + &user_two_chest, 50, scenario.ctx(), ); assert_eq!(safe_request.data().sender(), @0x1); assert_eq!(safe_request.data().recipient(), @0x2); - assert_eq!(safe_request.data().sender_vault_id(), user_one_vault_id); - assert_eq!(safe_request.data().recipient_vault_id(), user_two_vault_id); + assert_eq!(safe_request.data().sender_chest_id(), user_one_chest_id); + assert_eq!(safe_request.data().recipient_chest_id(), user_two_chest_id); assert_eq!(safe_request.data().amount(), 50); destroy(transfer_request); destroy(safe_request); - return_shared(user_one_vault); - return_shared(user_two_vault); + return_shared(user_one_chest); + return_shared(user_two_chest); }); } @@ -144,18 +144,18 @@ fun test_address_and_derivation_matches() { fun unlock_funds_successfully() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let auth = vault::new_auth(scenario.ctx()); - let mut unlock_request = vault.unlock_funds(&auth, 50, scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); + let mut unlock_request = chest.unlock_funds(&auth, 50, scenario.ctx()); unlock_request.approve(AWitness()); let balance = unlock_funds::resolve(unlock_request, managed_rule); assert_eq!(balance.value(), 50); - vault.share(); + chest.share(); balance.send_funds(@0x10); }); } @@ -164,11 +164,11 @@ fun unlock_funds_successfully() { fun try_to_resolve_unlock_funds_request_for_managed_assets() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let auth = vault::new_auth(scenario.ctx()); - let unlock_request = vault.unlock_funds(&auth, 50, scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); + let unlock_request = chest.unlock_funds(&auth, 50, scenario.ctx()); let _balance = unlock_funds::resolve_unrestricted(unlock_request, namespace); @@ -180,16 +180,16 @@ fun try_to_resolve_unlock_funds_request_for_managed_assets() { fun unlock_non_managed_funds() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let auth = vault::new_auth(scenario.ctx()); - let unlock_request = vault.unlock_funds(&auth, 100, scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); + let unlock_request = chest.unlock_funds(&auth, 100, scenario.ctx()); let balance = unlock_funds::resolve_unrestricted(unlock_request, namespace); balance.send_funds(@0x1); - vault.share(); + chest.share(); }); } @@ -214,14 +214,14 @@ fun try_to_transfer_unmanaged_assets() { // create a rule but do not enable funds management. let (rule, cap) = rule::new(namespace, internal::permit()); - // somehow transfer balance to vault a - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + // somehow transfer balance to chest a + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); // Try to authorize a transfer which cannot conclude until registration is finalized. - let auth = vault::new_auth(scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); - let transfer_request = vault.unsafe_transfer_funds( + let transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -241,13 +241,13 @@ fun try_to_unlock_unmanaged_assets() { // create a rule but do not enable funds management. let (rule, cap) = rule::new(namespace, internal::permit()); - // somehow transfer balance to vault a - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + // somehow transfer balance to chest a + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); // Try to authorize a transfer which cannot conclude until registration is finalized. - let auth = vault::new_auth(scenario.ctx()); - let unlock_request = vault.unlock_funds( + let auth = chest::new_auth(scenario.ctx()); + let unlock_request = chest.unlock_funds( &auth, 50, scenario.ctx(), @@ -263,12 +263,12 @@ fun try_to_unlock_unmanaged_assets() { fun derivation_is_consistent() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let vault = vault::create(namespace, @0x1); + let chest = chest::create(namespace, @0x1); - assert_eq!(namespace.vault_address(@0x1), object::id(&vault).to_address()); + assert_eq!(namespace.chest_address(@0x1), object::id(&chest).to_address()); assert_eq!(namespace.rule_address(), object::id(managed_rule).to_address()); - vault.share(); + chest.share(); }); } @@ -276,19 +276,19 @@ fun derivation_is_consistent() { fun test_unlock_request_getters() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); - let mut vault = vault::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + let mut chest = chest::create(namespace, @0x1); + chest.deposit_funds(balance::create_for_testing(100)); - let auth = vault::new_auth(scenario.ctx()); + let auth = chest::new_auth(scenario.ctx()); - let unlock_request = vault.unlock_funds(&auth, 50, scenario.ctx()); + let unlock_request = chest.unlock_funds(&auth, 50, scenario.ctx()); assert_eq!(unlock_request.data().owner(), @0x1); - assert_eq!(unlock_request.data().vault_id(), namespace.vault_address(@0x1).to_id()); + assert_eq!(unlock_request.data().chest_id(), namespace.chest_address(@0x1).to_id()); assert_eq!(unlock_request.data().amount(), 50); destroy(unlock_request); - vault.share(); + chest.share(); }); } @@ -318,23 +318,23 @@ fun multiple_approvals_required() { scenario.return_to_sender(rule_cap); - // create vaults of 0x1 and 0x2 - let vault = vault::create(namespace, @0x1); + // create chests of 0x1 and 0x2 + let chest = chest::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - vault.deposit_funds(balance::create_for_testing(100)); - vault.share(); + chest.deposit_funds(balance::create_for_testing(100)); + chest.share(); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.unsafe_transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -345,7 +345,7 @@ fun multiple_approvals_required() { transfer_request.approve(BWitness()); transfer_funds::resolve(transfer_request, managed_rule); - return_shared(vault); + return_shared(chest); }); } @@ -365,23 +365,23 @@ fun multiple_approvals_invalid_order_failure() { scenario.return_to_sender(rule_cap); - // create vaults of 0x1 and 0x2 - let vault = vault::create(namespace, @0x1); + // create chests of 0x1 and 0x2 + let chest = chest::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - vault.deposit_funds(balance::create_for_testing(100)); - vault.share(); + chest.deposit_funds(balance::create_for_testing(100)); + chest.share(); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.unsafe_transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -402,23 +402,23 @@ fun cannot_have_extra_approvals() { let namespace_id = object::id(namespace); - // create vaults of 0x1 and 0x2 - let vault = vault::create(namespace, @0x1); + // create chests of 0x1 and 0x2 + let chest = chest::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - vault.deposit_funds(balance::create_for_testing(100)); - vault.share(); + chest.deposit_funds(balance::create_for_testing(100)); + chest.share(); scenario.next_tx(@0x1); - let mut vault = scenario.take_shared_by_id(namespace - .vault_address( + let mut chest = scenario.take_shared_by_id(namespace + .chest_address( @0x1, ) .to_id()); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.unsafe_transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, diff --git a/packages/pas/tests/rule_setup_tests.move b/packages/pas/tests/rule_setup_tests.move index 7cd9796..4fe624b 100644 --- a/packages/pas/tests/rule_setup_tests.move +++ b/packages/pas/tests/rule_setup_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::rule_setup_tests; -use pas::{e2e::{test_tx, A}, rule::RuleCap, transfer_funds, vault}; +use pas::{e2e::{test_tx, A}, rule::RuleCap, transfer_funds, chest}; use sui::balance; public struct InvalidActionApproval() has drop; @@ -18,12 +18,12 @@ fun override_action_approval() { // Do a test transfer to verify the override auth works { - let mut vault = vault::create(namespace, @0x1); + let mut chest = chest::create(namespace, @0x1); - vault.deposit_funds(balance::create_for_testing(100)); + chest.deposit_funds(balance::create_for_testing(100)); - let auth = vault::new_auth(scenario.ctx()); - let mut transfer_request = vault.unsafe_transfer_funds( + let auth = chest::new_auth(scenario.ctx()); + let mut transfer_request = chest.unsafe_transfer_funds( &auth, @0x2, 50, @@ -32,7 +32,7 @@ fun override_action_approval() { transfer_request.approve(NewActionApproval()); transfer_funds::resolve(transfer_request, managed_rule); - vault.share(); + chest.share(); }; scenario.return_to_sender(rule_cap); diff --git a/packages/pas/tests/versioning_tests.move b/packages/pas/tests/versioning_tests.move index b1e1b2c..d6b7341 100644 --- a/packages/pas/tests/versioning_tests.move +++ b/packages/pas/tests/versioning_tests.move @@ -4,7 +4,7 @@ module pas::versioning_tests; use pas::{ e2e::{package_id, test_tx, A}, namespace::{Self, Namespace}, - vault, + chest, versioning::breaking_version }; use ptb::ptb::Command; @@ -70,52 +70,52 @@ fun tries_to_unblock_version_with_invalid_upgrade_cap() { } #[test] -fun block_unblock_versions_and_sync_with_vaults_and_rules() { +fun block_unblock_versions_and_sync_with_chests_and_rules() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { scenario.next_tx(@0x1); let upgrade_cap = scenario.take_from_sender(); - let mut vault = vault::create(namespace, @0x1); + let mut chest = chest::create(namespace, @0x1); namespace.block_version(&upgrade_cap, 1); assert!(!namespace.versioning().is_valid_version(1)); - vault.sync_versioning(namespace); + chest.sync_versioning(namespace); managed_rule.sync_versioning(namespace); - assert_eq!(vault.versioning(), namespace.versioning()); - assert!(!vault.versioning().is_valid_version(1)); + assert_eq!(chest.versioning(), namespace.versioning()); + assert!(!chest.versioning().is_valid_version(1)); assert!(!managed_rule.versioning().is_valid_version(1)); namespace.unblock_version(&upgrade_cap, 1); - vault.sync_versioning(namespace); + chest.sync_versioning(namespace); managed_rule.sync_versioning(namespace); assert!(namespace.versioning().is_valid_version(1)); - assert!(vault.versioning().is_valid_version(1)); + assert!(chest.versioning().is_valid_version(1)); assert!(managed_rule.versioning().is_valid_version(1)); - vault.share(); + chest.share(); scenario.return_to_sender(upgrade_cap); }); } #[test, expected_failure(abort_code = ::pas::versioning::EInvalidVersion)] -fun try_to_create_vault_with_invalid_version() { +fun try_to_create_chest_with_invalid_version() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { namespace.block_current_version(scenario); - let _vault = vault::create(namespace, @0x1); + let _chest = chest::create(namespace, @0x1); abort }); } #[test, expected_failure(abort_code = ::pas::versioning::EInvalidVersion)] -fun try_unlock_funds_invalid_version_on_vault() { +fun try_unlock_funds_invalid_version_on_chest() { test_tx!(@0x1, |namespace, managed_rule, _unmanaged_rule, scenario| { - let mut vault = vault::create(namespace, @0x1); + let mut chest = chest::create(namespace, @0x1); namespace.block_current_version(scenario); - vault.sync_versioning(namespace); - let auth = vault::new_auth(scenario.ctx()); - let req = vault.unlock_funds(&auth, 50, scenario.ctx()); + chest.sync_versioning(namespace); + let auth = chest::new_auth(scenario.ctx()); + let req = chest.unlock_funds(&auth, 50, scenario.ctx()); abort }); } diff --git a/sdk/example-app/src/extension-example.ts b/sdk/example-app/src/extension-example.ts index c796743..633c6c4 100644 --- a/sdk/example-app/src/extension-example.ts +++ b/sdk/example-app/src/extension-example.ts @@ -29,11 +29,11 @@ async function main(): Promise { // await finalizeTestAssetSetup(client); // console.log(await getBalancesForAddress(client, sender)); - // await createVaultForAddress(client, sender); - // await createVaultForAddress(client, '0x2'); + // await createChestForAddress(client, sender); + // await createChestForAddress(client, '0x2'); - // console.log(client.pas.deriveVaultAddress(sender)); - // await mintFromDemoFaucetAndTransferToVault(client, 10, sender); + // console.log(client.pas.deriveChestAddress(sender)); + // await mintFromDemoFaucetAndTransferToChest(client, 10, sender); const tx = new Transaction(); @@ -49,24 +49,24 @@ async function main(): Promise { main(); -// Queries the balances for address (both the addr balance, and the vault's balance.) +// Queries the balances for address (both the addr balance, and the chest's balance.) async function getBalancesForAddress(client: PasClientType, address: string) { const addr = normalizeSuiAddress(address); - const [addressBalance, vaultBalance] = await Promise.all([ + const [addressBalance, chestBalance] = await Promise.all([ client.core.getBalance({ owner: addr, coinType: assetType }), client.core.getBalance({ - owner: client.pas.deriveVaultAddress(address), + owner: client.pas.deriveChestAddress(address), coinType: assetType }) ]); - return { addressBalance, vaultBalance }; + return { addressBalance, chestBalance }; } -async function mintFromDemoFaucetAndTransferToVault(client: PasClientType, amount: number, owner: string) { +async function mintFromDemoFaucetAndTransferToChest(client: PasClientType, amount: number, owner: string) { const tx = new Transaction(); const balance = tx.moveCall({ @@ -76,7 +76,7 @@ async function mintFromDemoFaucetAndTransferToVault(client: PasClientType, amoun tx.moveCall({ target: `0x2::balance::send_funds`, - arguments: [balance, tx.pure.address(client.pas.deriveVaultAddress(owner))], + arguments: [balance, tx.pure.address(client.pas.deriveChestAddress(owner))], typeArguments: [assetType] }) @@ -94,9 +94,9 @@ async function finalizeTestAssetSetup(client: PasClientType) { await signAndExecute(client, tx); } -async function createVaultForAddress(client: PasClientType, address: string) { +async function createChestForAddress(client: PasClientType, address: string) { const tx = new Transaction(); - tx.add(client.pas.tx.vaultForAddress(address)); + tx.add(client.pas.tx.chestForAddress(address)); return signAndExecute(client, tx); } diff --git a/sdk/pas/src/client.ts b/sdk/pas/src/client.ts index da177af..a676f28 100644 --- a/sdk/pas/src/client.ts +++ b/sdk/pas/src/client.ts @@ -9,17 +9,17 @@ import { TESTNET_PAS_PACKAGE_CONFIG, } from './constants.js'; import { + deriveChestAddress, deriveRuleAddress, deriveTemplateAddress, deriveTemplateRegistryAddress, - deriveVaultAddress, } from './derivation.js'; import { PASClientError } from './error.js'; import { + chestForAddressIntent, transferFundsIntent, unlockFundsIntent, unlockUnrestrictedFundsIntent, - vaultForAddressIntent, } from './intents.js'; import type { PASClientConfig, PASOptions, PASPackageConfig } from './types.js'; @@ -104,13 +104,13 @@ export class PASClient { } /** - * Derives the vault address for a given owner address. + * Derives the chest address for a given owner address. * * @param owner - The owner address (can be a user address or object address) - * @returns The derived vault object ID + * @returns The derived chest object ID */ - deriveVaultAddress(owner: string): string { - return deriveVaultAddress(owner, this.#packageConfig); + deriveChestAddress(owner: string): string { + return deriveChestAddress(owner, this.#packageConfig); } /** @@ -152,11 +152,11 @@ export class PASClient { /** * Creates a transfer funds intent. At build time, it auto-resolves the issuer's * approval template commands by reading the Rule and Templates objects on-chain. - * If the recipient vault does not exist, it will be created and shared automatically. + * If the recipient chest does not exist, it will be created and shared automatically. * * @param options - Transfer options - * @param options.from - The sender's address (owner of the source vault) - * @param options.to - The receiver's address (owner of the destination vault) + * @param options.from - The sender's address (owner of the source chest) + * @param options.to - The receiver's address (owner of the destination chest) * @param options.amount - The amount to transfer * @param options.assetType - The full asset type (e.g., "0x2::sui::SUI") * @returns A sync closure `(tx: Transaction) => TransactionResult` @@ -169,7 +169,7 @@ export class PASClient { * unlock approvals for the asset type. * * @param options - Unlock options - * @param options.from - The sender's address (owner of the source vault) + * @param options.from - The sender's address (owner of the source chest) * @param options.amount - The amount to unlock * @param options.assetType - The full asset type (e.g., "0x2::sui::SUI") * @returns A sync closure `(tx: Transaction) => TransactionResult` @@ -181,7 +181,7 @@ export class PASClient { * Use this when no Rule exists for the asset type (e.g., SUI). * * @param options - Unlock options - * @param options.from - The sender's address (owner of the source vault) + * @param options.from - The sender's address (owner of the source chest) * @param options.amount - The amount to unlock * @param options.assetType - The full asset type (e.g., "0x2::sui::SUI") * @returns A sync closure `(tx: Transaction) => TransactionResult` @@ -189,14 +189,14 @@ export class PASClient { unlockUnrestrictedFunds: unlockUnrestrictedFundsIntent(this.#packageConfig), /** - * Returns a vault object for the given address. At build time, if the vault + * Returns a chest object for the given address. At build time, if the chest * already exists on-chain it resolves to an object reference; otherwise it - * creates the vault and shares it. + * creates the chest and shares it. * * @param owner - The owner address - * @returns A sync closure `(tx: Transaction) => TransactionResult` (the vault) + * @returns A sync closure `(tx: Transaction) => TransactionResult` (the chest) */ - vaultForAddress: vaultForAddressIntent(this.#packageConfig), + chestForAddress: chestForAddressIntent(this.#packageConfig), }; } } diff --git a/sdk/pas/src/contracts/pas/vault.ts b/sdk/pas/src/contracts/pas/chest.ts similarity index 86% rename from sdk/pas/src/contracts/pas/vault.ts rename to sdk/pas/src/contracts/pas/chest.ts index 203c10d..0db6717 100644 --- a/sdk/pas/src/contracts/pas/vault.ts +++ b/sdk/pas/src/contracts/pas/chest.ts @@ -2,7 +2,7 @@ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * **************************************************************/ -/** Vault logic */ +/** Chest logic */ import { bcs } from '@mysten/sui/bcs'; import { type Transaction } from '@mysten/sui/transactions'; @@ -15,15 +15,15 @@ import { } from '../utils/index.js'; import * as versioning from './versioning.js'; -const $moduleName = '@mysten/pas::vault'; -export const Vault = new MoveStruct({ - name: `${$moduleName}::Vault`, +const $moduleName = '@mysten/pas::chest'; +export const Chest = new MoveStruct({ + name: `${$moduleName}::Chest`, fields: { id: bcs.Address, - /** The owner of the vault (address or object) */ + /** The owner of the chest (address or object) */ owner: bcs.Address, /** - * The ID of the namespace that created this vault. There's ONLY ONE namespace in + * The ID of the namespace that created this chest. There's ONLY ONE namespace in * the system, but this helps us avoid having `&Namespace` inputs in all functions * that need to derive the IDs. */ @@ -46,7 +46,7 @@ export interface CreateOptions { | CreateArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -/** Create a new vault for `owner`. This is a permission-less action. */ +/** Create a new chest for `owner`. This is a permission-less action. */ export function create(options: CreateOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; @@ -54,30 +54,30 @@ export function create(options: CreateOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'create', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface ShareArguments { - vault: RawTransactionArgument; + chest: RawTransactionArgument; } export interface ShareOptions { package?: string; - arguments: ShareArguments | [vault: RawTransactionArgument]; + arguments: ShareArguments | [chest: RawTransactionArgument]; } /** - * The only way to finalize the TX is by sharing the vault. All vaults are shared + * The only way to finalize the TX is by sharing the chest. All chests are shared * by default. */ export function share(options: ShareOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['vault']; + const parameterNames = ['chest']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'share', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); @@ -92,7 +92,7 @@ export interface CreateAndShareOptions { | CreateAndShareArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -/** Create and share a vault in a single step. */ +/** Create and share a chest in a single step. */ export function createAndShare(options: CreateAndShareOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; @@ -100,13 +100,13 @@ export function createAndShare(options: CreateAndShareOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'create_and_share', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface UnlockFundsArguments { - vault: RawTransactionArgument; + chest: RawTransactionArgument; auth: RawTransactionArgument; amount: RawTransactionArgument; } @@ -115,7 +115,7 @@ export interface UnlockFundsOptions { arguments: | UnlockFundsArguments | [ - vault: RawTransactionArgument, + chest: RawTransactionArgument, auth: RawTransactionArgument, amount: RawTransactionArgument, ]; @@ -129,11 +129,11 @@ export interface UnlockFundsOptions { export function unlockFunds(options: UnlockFundsOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['vault', 'auth', 'amount']; + const parameterNames = ['chest', 'auth', 'amount']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'unlock_funds', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -157,7 +157,7 @@ export interface TransferFundsOptions { ]; typeArguments: [string]; } -/** Initiate a transfer from vault A to vault B. */ +/** Initiate a transfer from chest A to chest B. */ export function transferFunds(options: TransferFundsOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; @@ -165,7 +165,7 @@ export function transferFunds(options: TransferFundsOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'transfer_funds', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -195,7 +195,7 @@ export function clawbackFunds(options: ClawbackFundsOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'clawback_funds', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -220,7 +220,7 @@ export interface UnsafeTransferFundsOptions { typeArguments: [string]; } /** - * Transfer `amount` from vault to an address. This unlocks transfers to a vault + * Transfer `amount` from chest to an address. This unlocks transfers to a chest * before it has been created. * * It's marked as `unsafe_` as it's easy to accidentally pick the wrong recipient @@ -233,7 +233,7 @@ export function unsafeTransferFunds(options: UnsafeTransferFundsOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'unsafe_transfer_funds', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -249,7 +249,7 @@ export function newAuth(options: NewAuthOptions = {}) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'new_auth', }); } @@ -260,7 +260,7 @@ export interface NewAuthAsObjectOptions { package?: string; arguments: NewAuthAsObjectArguments | [uid: RawTransactionArgument]; } -/** Generate an ownership proof from a `UID` object, to allow objects to own vaults. */ +/** Generate an ownership proof from a `UID` object, to allow objects to own chests. */ export function newAuthAsObject(options: NewAuthAsObjectOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = ['0x2::object::ID'] satisfies (string | null)[]; @@ -268,73 +268,73 @@ export function newAuthAsObject(options: NewAuthAsObjectOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'new_auth_as_object', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface OwnerArguments { - vault: RawTransactionArgument; + chest: RawTransactionArgument; } export interface OwnerOptions { package?: string; - arguments: OwnerArguments | [vault: RawTransactionArgument]; + arguments: OwnerArguments | [chest: RawTransactionArgument]; } export function owner(options: OwnerOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['vault']; + const parameterNames = ['chest']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'owner', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface DepositFundsArguments { - vault: RawTransactionArgument; + chest: RawTransactionArgument; balance: RawTransactionArgument; } export interface DepositFundsOptions { package?: string; arguments: | DepositFundsArguments - | [vault: RawTransactionArgument, balance: RawTransactionArgument]; + | [chest: RawTransactionArgument, balance: RawTransactionArgument]; typeArguments: [string]; } export function depositFunds(options: DepositFundsOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['vault', 'balance']; + const parameterNames = ['chest', 'balance']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'deposit_funds', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SyncVersioningArguments { - vault: RawTransactionArgument; + chest: RawTransactionArgument; namespace: RawTransactionArgument; } export interface SyncVersioningOptions { package?: string; arguments: | SyncVersioningArguments - | [vault: RawTransactionArgument, namespace: RawTransactionArgument]; + | [chest: RawTransactionArgument, namespace: RawTransactionArgument]; } /** Permission-less operation to bring versioning up-to-date with the namespace. */ export function syncVersioning(options: SyncVersioningOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['vault', 'namespace']; + const parameterNames = ['chest', 'namespace']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'vault', + module: 'chest', function: 'sync_versioning', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); diff --git a/sdk/pas/src/contracts/pas/clawback_funds.ts b/sdk/pas/src/contracts/pas/clawback_funds.ts index 9fbdca0..0159fcd 100644 --- a/sdk/pas/src/contracts/pas/clawback_funds.ts +++ b/sdk/pas/src/contracts/pas/clawback_funds.ts @@ -11,10 +11,10 @@ const $moduleName = '@mysten/pas::clawback_funds'; export const ClawbackFunds = new MoveStruct({ name: `${$moduleName}::ClawbackFunds`, fields: { - /** `owner` is the wallet OR object address, NOT the vault address */ + /** `owner` is the wallet OR object address, NOT the chest address */ owner: bcs.Address, - /** The ID of the vault the funds are coming from */ - vault_id: bcs.Address, + /** The ID of the chest the funds are coming from */ + chest_id: bcs.Address, /** The balance that is being clawed back. */ balance: balance.Balance, }, @@ -40,15 +40,15 @@ export function owner(options: OwnerOptions) { typeArguments: options.typeArguments, }); } -export interface VaultIdArguments { +export interface ChestIdArguments { request: RawTransactionArgument; } -export interface VaultIdOptions { +export interface ChestIdOptions { package?: string; - arguments: VaultIdArguments | [request: RawTransactionArgument]; + arguments: ChestIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function vaultId(options: VaultIdOptions) { +export function chestId(options: ChestIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -56,7 +56,7 @@ export function vaultId(options: VaultIdOptions) { tx.moveCall({ package: packageAddress, module: 'clawback_funds', - function: 'vault_id', + function: 'chest_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); diff --git a/sdk/pas/src/contracts/pas/keys.ts b/sdk/pas/src/contracts/pas/keys.ts index 16b8441..3862d8f 100644 --- a/sdk/pas/src/contracts/pas/keys.ts +++ b/sdk/pas/src/contracts/pas/keys.ts @@ -8,7 +8,7 @@ import { MoveTuple, normalizeMoveArguments, type RawTransactionArgument } from ' const $moduleName = '@mysten/pas::keys'; export const RuleKey = new MoveTuple({ name: `${$moduleName}::RuleKey`, fields: [bcs.bool()] }); -export const VaultKey = new MoveTuple({ name: `${$moduleName}::VaultKey`, fields: [bcs.Address] }); +export const ChestKey = new MoveTuple({ name: `${$moduleName}::ChestKey`, fields: [bcs.Address] }); export const TemplateKey = new MoveTuple({ name: `${$moduleName}::TemplateKey`, fields: [bcs.bool()], diff --git a/sdk/pas/src/contracts/pas/namespace.ts b/sdk/pas/src/contracts/pas/namespace.ts index d8b7381..f110ec0 100644 --- a/sdk/pas/src/contracts/pas/namespace.ts +++ b/sdk/pas/src/contracts/pas/namespace.ts @@ -7,7 +7,7 @@ * * Namespace is responsible for creating objects that are easy to query & find: * - * 1. Vaults + * 1. Chests * 2. Rules ... any other module we might add in the future */ @@ -163,17 +163,17 @@ export function ruleAddress(options: RuleAddressOptions) { typeArguments: options.typeArguments, }); } -export interface VaultExistsArguments { +export interface ChestExistsArguments { namespace: RawTransactionArgument; owner: RawTransactionArgument; } -export interface VaultExistsOptions { +export interface ChestExistsOptions { package?: string; arguments: - | VaultExistsArguments + | ChestExistsArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -export function vaultExists(options: VaultExistsOptions) { +export function chestExists(options: ChestExistsOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; const parameterNames = ['namespace', 'owner']; @@ -181,21 +181,21 @@ export function vaultExists(options: VaultExistsOptions) { tx.moveCall({ package: packageAddress, module: 'namespace', - function: 'vault_exists', + function: 'chest_exists', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } -export interface VaultAddressArguments { +export interface ChestAddressArguments { namespace: RawTransactionArgument; owner: RawTransactionArgument; } -export interface VaultAddressOptions { +export interface ChestAddressOptions { package?: string; arguments: - | VaultAddressArguments + | ChestAddressArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -export function vaultAddress(options: VaultAddressOptions) { +export function chestAddress(options: ChestAddressOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; const parameterNames = ['namespace', 'owner']; @@ -203,7 +203,7 @@ export function vaultAddress(options: VaultAddressOptions) { tx.moveCall({ package: packageAddress, module: 'namespace', - function: 'vault_address', + function: 'chest_address', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } diff --git a/sdk/pas/src/contracts/pas/transfer_funds.ts b/sdk/pas/src/contracts/pas/transfer_funds.ts index f79d295..3a1b758 100644 --- a/sdk/pas/src/contracts/pas/transfer_funds.ts +++ b/sdk/pas/src/contracts/pas/transfer_funds.ts @@ -11,14 +11,14 @@ const $moduleName = '@mysten/pas::transfer_funds'; export const TransferFunds = new MoveStruct({ name: `${$moduleName}::TransferFunds`, fields: { - /** `sender` is the wallet OR object address, NOT the vault address */ + /** `sender` is the wallet OR object address, NOT the chest address */ sender: bcs.Address, - /** `recipient` is the wallet OR object address, NOT the vault address */ + /** `recipient` is the wallet OR object address, NOT the chest address */ recipient: bcs.Address, - /** The ID of the vault the funds are coming from */ - sender_vault_id: bcs.Address, - /** The ID of the vault the funds are going to */ - recipient_vault_id: bcs.Address, + /** The ID of the chest the funds are coming from */ + sender_chest_id: bcs.Address, + /** The ID of the chest the funds are going to */ + recipient_chest_id: bcs.Address, /** The amount being transferred (original) */ amount: bcs.u64(), /** The actual balance being transferred */ @@ -67,15 +67,15 @@ export function recipient(options: RecipientOptions) { typeArguments: options.typeArguments, }); } -export interface SenderVaultIdArguments { +export interface SenderChestIdArguments { request: RawTransactionArgument; } -export interface SenderVaultIdOptions { +export interface SenderChestIdOptions { package?: string; - arguments: SenderVaultIdArguments | [request: RawTransactionArgument]; + arguments: SenderChestIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function senderVaultId(options: SenderVaultIdOptions) { +export function senderChestId(options: SenderChestIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -83,20 +83,20 @@ export function senderVaultId(options: SenderVaultIdOptions) { tx.moveCall({ package: packageAddress, module: 'transfer_funds', - function: 'sender_vault_id', + function: 'sender_chest_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } -export interface RecipientVaultIdArguments { +export interface RecipientChestIdArguments { request: RawTransactionArgument; } -export interface RecipientVaultIdOptions { +export interface RecipientChestIdOptions { package?: string; - arguments: RecipientVaultIdArguments | [request: RawTransactionArgument]; + arguments: RecipientChestIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function recipientVaultId(options: RecipientVaultIdOptions) { +export function recipientChestId(options: RecipientChestIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -104,7 +104,7 @@ export function recipientVaultId(options: RecipientVaultIdOptions) { tx.moveCall({ package: packageAddress, module: 'transfer_funds', - function: 'recipient_vault_id', + function: 'recipient_chest_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); diff --git a/sdk/pas/src/contracts/pas/unlock_funds.ts b/sdk/pas/src/contracts/pas/unlock_funds.ts index 520c3cf..8daf62e 100644 --- a/sdk/pas/src/contracts/pas/unlock_funds.ts +++ b/sdk/pas/src/contracts/pas/unlock_funds.ts @@ -11,10 +11,10 @@ const $moduleName = '@mysten/pas::unlock_funds'; export const UnlockFunds = new MoveStruct({ name: `${$moduleName}::UnlockFunds`, fields: { - /** `from` is the wallet OR object address, NOT the vault address */ + /** `from` is the wallet OR object address, NOT the chest address */ owner: bcs.Address, - /** The ID of the vault the funds are coming from */ - vault_id: bcs.Address, + /** The ID of the chest the funds are coming from */ + chest_id: bcs.Address, /** The amount being transferred (initial amount) */ amount: bcs.u64(), /** The actual balance being transferred */ @@ -42,15 +42,15 @@ export function owner(options: OwnerOptions) { typeArguments: options.typeArguments, }); } -export interface VaultIdArguments { +export interface ChestIdArguments { request: RawTransactionArgument; } -export interface VaultIdOptions { +export interface ChestIdOptions { package?: string; - arguments: VaultIdArguments | [request: RawTransactionArgument]; + arguments: ChestIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function vaultId(options: VaultIdOptions) { +export function chestId(options: ChestIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -58,7 +58,7 @@ export function vaultId(options: VaultIdOptions) { tx.moveCall({ package: packageAddress, module: 'unlock_funds', - function: 'vault_id', + function: 'chest_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); @@ -100,7 +100,7 @@ export interface ResolveUnrestrictedOptions { * If a `Rule` exists, they can only be resolved from within the system. * * For example, `SUI` will never be a managed asset, so the owner needs to be able - * to withdraw if anyone transfers some to their vault. + * to withdraw if anyone transfers some to their chest. */ export function resolveUnrestricted(options: ResolveUnrestrictedOptions) { const packageAddress = options.package ?? '@mysten/pas'; diff --git a/sdk/pas/src/derivation.ts b/sdk/pas/src/derivation.ts index 80aeec9..d2f8170 100644 --- a/sdk/pas/src/derivation.ts +++ b/sdk/pas/src/derivation.ts @@ -7,28 +7,28 @@ import { deriveDynamicFieldID, deriveObjectID, normalizeSuiAddress } from '@myst import type { PASPackageConfig } from './types.js'; /** - * Derives the vault address for a given owner address. + * Derives the chest address for a given owner address. * - * Vaults are derived using the namespace UID and a VaultKey(owner). - * The key structure in Move is: `VaultKey(address)` + * Chests are derived using the namespace UID and a ChestKey(owner). + * The key structure in Move is: `ChestKey(address)` * * @param owner - The owner address (can be a user address or object address) * @param packageConfig - PAS package configuration - * @returns The derived vault object ID + * @returns The derived chest object ID */ -export function deriveVaultAddress(owner: string, packageConfig: PASPackageConfig): string { +export function deriveChestAddress(owner: string, packageConfig: PASPackageConfig): string { const { packageId, namespaceId } = packageConfig; - // Serialize the VaultKey(address) as the key - // VaultKey is a struct with a single field: address - const vaultKeyBcs = bcs.struct('VaultKey', { + // Serialize the ChestKey(address) as the key + // ChestKey is a struct with a single field: address + const chestKeyBcs = bcs.struct('ChestKey', { owner: bcs.Address, }); - const key = vaultKeyBcs.serialize({ owner: normalizeSuiAddress(owner) }).toBytes(); + const key = chestKeyBcs.serialize({ owner: normalizeSuiAddress(owner) }).toBytes(); - // The type tag is the VaultKey type from the PAS package - const typeTag = `${packageId}::keys::VaultKey`; + // The type tag is the ChestKey type from the PAS package + const typeTag = `${packageId}::keys::ChestKey`; return deriveObjectID(namespaceId, typeTag, key); } diff --git a/sdk/pas/src/intents.ts b/sdk/pas/src/intents.ts index bfc6ff8..b6ad18e 100644 --- a/sdk/pas/src/intents.ts +++ b/sdk/pas/src/intents.ts @@ -15,10 +15,10 @@ import type { import { normalizeStructTag } from '@mysten/sui/utils'; import { + deriveChestAddress, deriveRuleAddress, deriveTemplateAddress, deriveTemplateRegistryAddress, - deriveVaultAddress, } from './derivation.js'; import { PASClientError, RuleNotFoundError } from './error.js'; import { @@ -60,8 +60,8 @@ type UnlockUnrestrictedFundsIntentData = { cfg: PASPackageConfig; }; -type VaultForAddressIntentData = { - action: 'vaultForAddress'; +type ChestForAddressIntentData = { + action: 'chestForAddress'; owner: string; cfg: PASPackageConfig; }; @@ -70,7 +70,7 @@ type PASIntentData = | TransferFundsIntentData | UnlockFundsIntentData | UnlockUnrestrictedFundsIntentData - | VaultForAddressIntentData; + | ChestForAddressIntentData; /** * Creates a memoized PAS intent closure. On first call it registers the @@ -146,11 +146,11 @@ export function unlockUnrestrictedFundsIntent( }); } -export function vaultForAddressIntent( +export function chestForAddressIntent( packageConfig: PASPackageConfig, ): (owner: string) => (tx: Transaction) => TransactionResult { return (owner: string) => - createPASIntent({ action: 'vaultForAddress', owner, cfg: packageConfig }); + createPASIntent({ action: 'chestForAddress', owner, cfg: packageConfig }); } // --------------------------------------------------------------------------- @@ -171,7 +171,7 @@ export function vaultForAddressIntent( // // baseIdx = the position of the $Intent slot being replaced // -// So if baseIdx is 3 and we push 2 vault-creation commands before the +// So if baseIdx is 3 and we push 2 chest-creation commands before the // new_auth call, new_auth lands at absolute index 5 (= 3 + 2). // // The SDK's `replaceCommand` handles index shifting automatically: after @@ -187,7 +187,7 @@ export function vaultForAddressIntent( type SuiObject = SuiClientTypes.Object<{ content: true }>; -type VaultState = { kind: 'existing' } | { kind: 'created'; resultIndex: number }; +type ChestState = { kind: 'existing' } | { kind: 'created'; resultIndex: number }; /** Return value from each per-action builder. */ interface BuildResult { @@ -197,14 +197,14 @@ interface BuildResult { } class Resolver { - /** Pre-fetched on-chain objects (vaults, rules). null = does not exist. */ + /** Pre-fetched on-chain objects (chests, rules). null = does not exist. */ readonly objects: Map; /** Pre-fetched template dynamic field objects. */ readonly templates: Map; /** Pre-parsed template lookup: ruleId:actionType -> approval type names. */ readonly templateApprovals: Map; - /** Vault existence / creation tracking. */ - readonly vaults: Map; + /** Chest existence / creation tracking. */ + readonly chests: Map; readonly #tx: TransactionDataBuilder; readonly #inputCache = new Map(); @@ -216,21 +216,21 @@ class Resolver { objects, templates, templateApprovals, - vaults, + chests, config, }: { transactionData: TransactionDataBuilder; objects: Map; templates: Map; templateApprovals: Map; - vaults: Map; + chests: Map; config: PASPackageConfig; }) { this.#tx = transactionData; this.objects = objects; this.templates = templates; this.templateApprovals = templateApprovals; - this.vaults = vaults; + this.chests = chests; this.#config = config; } @@ -272,26 +272,26 @@ class Resolver { return obj; } - // -- Vault resolution ---------------------------------------------------- + // -- Chest resolution ---------------------------------------------------- /** - * Returns an Argument referencing the vault for `vaultId`. + * Returns an Argument referencing the chest for `chestId`. * - * - Existing on-chain vault: returns an object Input. + * - Existing on-chain chest: returns an object Input. * - Already created earlier in this PTB: returns the stored Result ref. - * - Does not exist yet: **pushes** a `vault::create` MoveCall into the + * - Does not exist yet: **pushes** a `chest::create` MoveCall into the * caller's `commands` array (mutating it) and records the creation so - * subsequent calls for the same vault reuse the same Result. The vault - * will be shared at the end of the PTB via `shareNewVaults()`. + * subsequent calls for the same chest reuse the same Result. The chest + * will be shared at the end of the PTB via `shareNewChests()`. * * @param commands - The caller's local command array (may be mutated). * @param baseIdx - Absolute PTB index where `commands[0]` will land. */ - resolveVaultArg(vaultId: string, owner: string, baseIdx: number): [Argument, Command[]] { - const state = this.vaults.get(vaultId); + resolveChestArg(chestId: string, owner: string, baseIdx: number): [Argument, Command[]] { + const state = this.chests.get(chestId); const commands: Command[] = []; - if (state?.kind === 'existing') return [this.addObjectInput(vaultId), commands]; + if (state?.kind === 'existing') return [this.addObjectInput(chestId), commands]; if (state?.kind === 'created') return [{ $kind: 'Result', Result: state.resultIndex }, commands]; @@ -300,7 +300,7 @@ class Resolver { commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'create', arguments: [ this.addObjectInput(this.#config.namespaceId), @@ -309,7 +309,7 @@ class Resolver { }), ); - this.vaults.set(vaultId, { kind: 'created', resultIndex: absoluteIndex }); + this.chests.set(chestId, { kind: 'created', resultIndex: absoluteIndex }); return [{ $kind: 'Result', Result: absoluteIndex }, commands]; } @@ -353,23 +353,23 @@ class Resolver { } /** - * Replaces a vaultForAddress intent when the vault already exists. + * Replaces a chestForAddress intent when the chest already exists. * The intent is removed (0 replacement commands) and external references - * are remapped to the existing vault's Input argument. + * are remapped to the existing chest's Input argument. * * Note: SDK's replaceCommand signature doesn't accept Input args as * resultIndex, but the runtime handles it correctly via ArgumentSchema.parse(). */ - replaceIntentWithExistingVault(actualIdx: number, vaultArg: Argument) { - this.#tx.replaceCommand(actualIdx, [], vaultArg as any); + replaceIntentWithExistingChest(actualIdx: number, chestArg: Argument) { + this.#tx.replaceCommand(actualIdx, [], chestArg as any); } /** - * Replaces a vaultForAddress intent when the vault needs to be created. - * The intent is replaced with the vault::create command(s), and external - * references are remapped to the first command's Result (the new vault). + * Replaces a chestForAddress intent when the chest needs to be created. + * The intent is replaced with the chest::create command(s), and external + * references are remapped to the first command's Result (the new chest). */ - replaceIntentWithCreatedVault(actualIdx: number, commands: Command[]) { + replaceIntentWithCreatedChest(actualIdx: number, commands: Command[]) { this.#tx.replaceCommand(actualIdx, commands, { Result: actualIdx }); } @@ -380,9 +380,9 @@ class Resolver { // reference each other using absolute indices (baseIdx + local offset). // // The general pattern for a transfer is: - // [vault::create (0..N)] -- only if vaults don't exist yet - // vault::new_auth -- create ownership proof - // vault::transfer_funds -- initiate the request + // [chest::create (0..N)] -- only if chests don't exist yet + // chest::new_auth -- create ownership proof + // chest::transfer_funds -- initiate the request // [approval commands] -- issuer-defined template commands // transfer_funds::resolve -- finalize and produce the output // @@ -391,8 +391,8 @@ class Resolver { buildTransferFunds(data: TransferFundsIntentData, baseIdx: number): BuildResult { const { from, to, assetType, amount } = data; - const fromVaultId = deriveVaultAddress(from, this.#config); - const toVaultId = deriveVaultAddress(to, this.#config); + const fromChestId = deriveChestAddress(from, this.#config); + const toChestId = deriveChestAddress(to, this.#config); const ruleId = deriveRuleAddress(assetType, this.#config); const ruleObject = this.getObjectOrThrow(ruleId, () => new RuleNotFoundError(assetType)); @@ -401,37 +401,37 @@ class Resolver { PASActionType.TransferFunds, ); - const [toVaultArg, commands] = this.resolveVaultArg(toVaultId, to, baseIdx); - const [fromVaultArg, fromVaultCommands] = this.resolveVaultArg( - fromVaultId, + const [toChestArg, commands] = this.resolveChestArg(toChestId, to, baseIdx); + const [fromChestArg, fromChestCommands] = this.resolveChestArg( + fromChestId, from, baseIdx + commands.length, ); - commands.push(...fromVaultCommands); + commands.push(...fromChestCommands); const ruleArg = this.addObjectInput(ruleId); - // vault::new_auth + // chest::new_auth const authIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'new_auth', }), ); - // vault::transfer_funds + // chest::transfer_funds const requestIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'transfer_funds', arguments: [ - fromVaultArg, + fromChestArg, { $kind: 'Result', Result: authIdx }, - toVaultArg, + toChestArg, this.addTemplateInput('pure', Inputs.Pure(bcs.u64().serialize(BigInt(amount)))), ], typeArguments: [normalizeStructTag(assetType)], @@ -444,8 +444,8 @@ class Resolver { commands.push( buildMoveCallCommandFromTemplate(templateCmd, { addInput: (type, arg) => this.addTemplateInput(type, arg), - senderVault: fromVaultArg, - receiverVault: toVaultArg, + senderChest: fromChestArg, + receiverChest: toChestArg, rule: ruleArg, request: requestArg, systemType: assetType, @@ -478,7 +478,7 @@ class Resolver { baseIdx: number, ): BuildResult { const { from, assetType, amount } = data; - const fromVaultId = deriveVaultAddress(from, this.#config); + const fromChestId = deriveChestAddress(from, this.#config); const ruleId = deriveRuleAddress(assetType, this.#config); const isRestricted = data.action === 'unlockFunds'; @@ -501,28 +501,28 @@ class Resolver { } } - const [fromVaultArg, commands] = this.resolveVaultArg(fromVaultId, from, baseIdx); + const [fromChestArg, commands] = this.resolveChestArg(fromChestId, from, baseIdx); const ruleArg = isRestricted ? this.addObjectInput(ruleId) : undefined; - // vault::new_auth + // chest::new_auth const authIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'new_auth', }), ); - // vault::unlock_funds + // chest::unlock_funds const requestIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'unlock_funds', arguments: [ - fromVaultArg, + fromChestArg, { $kind: 'Result', Result: authIdx }, this.addTemplateInput('pure', Inputs.Pure(bcs.u64().serialize(BigInt(amount)))), ], @@ -538,7 +538,7 @@ class Resolver { commands.push( buildMoveCallCommandFromTemplate(templateCmd, { addInput: (type, arg) => this.addTemplateInput(type, arg), - senderVault: fromVaultArg, + senderChest: fromChestArg, rule: ruleArg, request: requestArg, systemType: assetType, @@ -577,18 +577,18 @@ class Resolver { // -- Finalization --------------------------------------------------------- /** - * Appends `vault::share` commands for every vault that was created during + * Appends `chest::share` commands for every chest that was created during * resolution. Called once at the end, after all intents have been resolved, - * so that each vault is shared exactly once regardless of how many intents + * so that each chest is shared exactly once regardless of how many intents * referenced it. */ - shareNewVaults() { - for (const state of this.vaults.values()) { + shareNewChests() { + for (const state of this.chests.values()) { if (state.kind !== 'created') continue; this.#tx.commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'vault', + module: 'chest', function: 'share', arguments: [{ $kind: 'Result', Result: state.resultIndex }], }), @@ -601,11 +601,11 @@ class Resolver { // Data collection + fetching (pre-resolution) // --------------------------------------------------------------------------- -type VaultOwner = { owner: string }; +type ChestOwner = { owner: string }; interface IntentDataCollection { objectIds: Set; - vaultRequests: Map; + chestRequests: Map; intentDataList: PASIntentData[]; cfg: PASPackageConfig; } @@ -613,7 +613,7 @@ interface IntentDataCollection { /** Scans commands for PAS intents and collects the object IDs we need to fetch. */ function collectIntentData(commands: readonly Command[]): IntentDataCollection | null { const objectIds = new Set(); - const vaultRequests = new Map(); + const chestRequests = new Map(); const intentDataList: PASIntentData[] = []; let cfg: PASPackageConfig | null = null; @@ -626,27 +626,27 @@ function collectIntentData(commands: readonly Command[]): IntentDataCollection | switch (data.action) { case 'transferFunds': { - const fromId = deriveVaultAddress(data.from, cfg); - const toId = deriveVaultAddress(data.to, cfg); + const fromId = deriveChestAddress(data.from, cfg); + const toId = deriveChestAddress(data.to, cfg); objectIds.add(fromId); objectIds.add(toId); objectIds.add(deriveRuleAddress(data.assetType, cfg)); - vaultRequests.set(fromId, { owner: data.from }); - vaultRequests.set(toId, { owner: data.to }); + chestRequests.set(fromId, { owner: data.from }); + chestRequests.set(toId, { owner: data.to }); break; } case 'unlockFunds': case 'unlockUnrestrictedFunds': { - const fromId = deriveVaultAddress(data.from, cfg); + const fromId = deriveChestAddress(data.from, cfg); objectIds.add(fromId); objectIds.add(deriveRuleAddress(data.assetType, cfg)); - vaultRequests.set(fromId, { owner: data.from }); + chestRequests.set(fromId, { owner: data.from }); break; } - case 'vaultForAddress': { - const id = deriveVaultAddress(data.owner, cfg); + case 'chestForAddress': { + const id = deriveChestAddress(data.owner, cfg); objectIds.add(id); - vaultRequests.set(id, { owner: data.owner }); + chestRequests.set(id, { owner: data.owner }); break; } } @@ -655,18 +655,18 @@ function collectIntentData(commands: readonly Command[]): IntentDataCollection | if (!cfg) throw new PASClientError('No package configuration found in intents. This is an internal bug.'); - return intentDataList.length > 0 ? { objectIds, vaultRequests, intentDataList, cfg } : null; + return intentDataList.length > 0 ? { objectIds, chestRequests, intentDataList, cfg } : null; } async function initializeContext( transactionData: TransactionDataBuilder, client: ClientWithCoreApi, objectIds: Set, - vaultRequests: Map, + chestRequests: Map, intentDataList: PASIntentData[], config: PASPackageConfig, ): Promise { - // 1. Batch-fetch all vaults + rules + // 1. Batch-fetch all chests + rules const allIds = [...objectIds]; const { objects: fetched } = await client.core.getObjects({ objectIds: allIds, @@ -680,11 +680,11 @@ async function initializeContext( objects.set(id, obj ?? null); } - // 2. Build initial vault map (existing vs needs-creation) - const vaults = new Map(); - for (const [vaultId] of vaultRequests) { - if (objects.get(vaultId) !== null) { - vaults.set(vaultId, { kind: 'existing' }); + // 2. Build initial chest map (existing vs needs-creation) + const chests = new Map(); + for (const [chestId] of chestRequests) { + if (objects.get(chestId) !== null) { + chests.set(chestId, { kind: 'existing' }); } } @@ -741,7 +741,7 @@ async function initializeContext( objects, templates, templateApprovals, - vaults, + chests, config, }); } @@ -756,13 +756,13 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption const requirements = collectIntentData(transactionData.commands); if (!requirements) return next(); - const { objectIds, vaultRequests, intentDataList, cfg } = requirements; + const { objectIds, chestRequests, intentDataList, cfg } = requirements; const ctx = await initializeContext( transactionData, client, objectIds, - vaultRequests, + chestRequests, intentDataList, cfg, ); @@ -775,15 +775,15 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption const data = command.$Intent.data as unknown as PASIntentData; - // -- vaultForAddress is handled separately (may produce 0 commands) -- - if (data.action === 'vaultForAddress') { - const vaultId = deriveVaultAddress(data.owner, cfg); - const [vaultArg, commands] = ctx.resolveVaultArg(vaultId, data.owner, index); + // -- chestForAddress is handled separately (may produce 0 commands) -- + if (data.action === 'chestForAddress') { + const chestId = deriveChestAddress(data.owner, cfg); + const [chestArg, commands] = ctx.resolveChestArg(chestId, data.owner, index); if (commands.length === 0) { - ctx.replaceIntentWithExistingVault(index, vaultArg); + ctx.replaceIntentWithExistingChest(index, chestArg); } else { - ctx.replaceIntentWithCreatedVault(index, commands); + ctx.replaceIntentWithCreatedChest(index, commands); } continue; } @@ -805,6 +805,6 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption ctx.replaceIntent(index, result.commands, result.resultOffset); } - ctx.shareNewVaults(); + ctx.shareNewChests(); return next(); }; diff --git a/sdk/pas/src/resolution.ts b/sdk/pas/src/resolution.ts index eb9cb1d..96d5d37 100644 --- a/sdk/pas/src/resolution.ts +++ b/sdk/pas/src/resolution.ts @@ -20,11 +20,11 @@ const RECEIVING_BY_ID_EXT = 'receiving_by_id'; * Supported PAS action types that can be resolved via Rules. */ export enum PASActionType { - /** Transfer funds between vaults */ + /** Transfer funds between chests */ TransferFunds = 'transfer_funds', - /** Unlock funds from a vault */ + /** Unlock funds from a chest */ UnlockFunds = 'unlock_funds', - /** Clawback funds from a vault */ + /** Clawback funds from a chest */ ClawbackFunds = 'clawback_funds', } @@ -89,10 +89,10 @@ function parseCommand([key, cmd]: ReturnType) { interface RawCommandBuildArgs { /** Adds an input to the parent transaction and returns the Argument ref. */ addInput: (type: 'object' | 'pure', arg: CallArg) => Argument; - /** The sender vault argument (already resolved) */ - senderVault?: Argument; - /** The receiver vault argument (already resolved) */ - receiverVault?: Argument; + /** The sender chest argument (already resolved) */ + senderChest?: Argument; + /** The receiver chest argument (already resolved) */ + receiverChest?: Argument; /** The rule argument (already resolved) */ rule?: Argument; /** The request argument (already resolved) */ @@ -229,13 +229,13 @@ function resolveRawPasRequest(args: RawCommandBuildArgs, value: string): Argumen case 'pas:rule': if (!args.rule) throw new PASClientError(`Rule is not set in the context.`); return args.rule; - case 'pas:sender_vault': - if (!args.senderVault) throw new PASClientError(`Sender vault is not set in the context.`); - return args.senderVault; - case 'pas:receiver_vault': - if (!args.receiverVault) - throw new PASClientError(`Receiver vault is not set in the context.`); - return args.receiverVault; + case 'pas:sender_chest': + if (!args.senderChest) throw new PASClientError(`Sender chest is not set in the context.`); + return args.senderChest; + case 'pas:receiver_chest': + if (!args.receiverChest) + throw new PASClientError(`Receiver chest is not set in the context.`); + return args.receiverChest; default: throw new PASClientError(`Unknown pas request: ${value}`); } diff --git a/sdk/pas/test/e2e/e2e.isolated.test.ts b/sdk/pas/test/e2e/e2e.isolated.test.ts index 811f5f2..0373e32 100644 --- a/sdk/pas/test/e2e/e2e.isolated.test.ts +++ b/sdk/pas/test/e2e/e2e.isolated.test.ts @@ -7,10 +7,10 @@ import { setupToolbox, simulateFailingTransaction, type TestToolbox } from './se async function expectBalances( toolbox: TestToolbox, - expected: { vault: string; asset: string; amount: number }[], + expected: { chest: string; asset: string; amount: number }[], ) { const balances = await Promise.all( - expected.map(({ vault, asset }) => toolbox.getBalance(vault, asset)), + expected.map(({ chest, asset }) => toolbox.getBalance(chest, asset)), ); for (const [idx, { amount }] of expected.entries()) { expect(Number(balances[idx].balance.balance)).toBe(amount * 1_000_000); @@ -22,14 +22,14 @@ describe.concurrent( () => { it('unlocks non-managed funds (e.g. SUI), but only through the unrestricted unlock flow', async () => { const toolbox = await setupToolbox(); - const vaultId = toolbox.client.pas.deriveVaultAddress(toolbox.address()); + const chestId = toolbox.client.pas.deriveChestAddress(toolbox.address()); const suiTypeName = normalizeStructTag('0x2::sui::SUI').toString(); - const { balance } = await toolbox.getBalance(vaultId, suiTypeName); + const { balance } = await toolbox.getBalance(chestId, suiTypeName); expect(Number(balance.balance)).toBe(0); - // Transfer 1 SUI to the vault. + // Transfer 1 SUI to the chest. const fundTransferTx = new Transaction(); const sui = fundTransferTx.splitCoins(fundTransferTx.gas, [ fundTransferTx.pure.u64(1_000_000_000), @@ -42,16 +42,16 @@ describe.concurrent( }); fundTransferTx.moveCall({ target: '0x2::balance::send_funds', - arguments: [into_balance, fundTransferTx.pure.address(vaultId)], + arguments: [into_balance, fundTransferTx.pure.address(chestId)], typeArguments: [suiTypeName], }); await toolbox.executeTransaction(fundTransferTx); - // Create the vault for the address. - await toolbox.createVaultForAddress(toolbox.address()); + // Create the chest for the address. + await toolbox.createChestForAddress(toolbox.address()); - const { balance: vaultBalanceAfterTransfer } = await toolbox.getBalance(vaultId, suiTypeName); - expect(Number(vaultBalanceAfterTransfer.balance)).toBe(1_000_000_000); + const { balance: chestBalanceAfterTransfer } = await toolbox.getBalance(chestId, suiTypeName); + expect(Number(chestBalanceAfterTransfer.balance)).toBe(1_000_000_000); // try to do an unlock but it should fail because `rule` for Sui does not exist. const tx = new Transaction(); @@ -84,11 +84,11 @@ describe.concurrent( await toolbox.executeTransaction(unlockTx); - const { balance: vaultBalanceAfterUnlock } = await toolbox.getBalance(vaultId, suiTypeName); - expect(Number(vaultBalanceAfterUnlock.balance)).toBe(0); + const { balance: chestBalanceAfterUnlock } = await toolbox.getBalance(chestId, suiTypeName); + expect(Number(chestBalanceAfterUnlock.balance)).toBe(0); }); - it('Should be able to transfer between vaults, going through the rule of the issuer;', async () => { + it('Should be able to transfer between chests, going through the rule of the issuer;', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createRule(); @@ -96,17 +96,17 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromVaultId = toolbox.client.pas.deriveVaultAddress(from); - const toVaultId = toolbox.client.pas.deriveVaultAddress(to); + const fromChestId = toolbox.client.pas.deriveChestAddress(from); + const toChestId = toolbox.client.pas.deriveChestAddress(to); - await toolbox.createVaultForAddress(from); - await toolbox.createVaultForAddress(to); + await toolbox.createChestForAddress(from); + await toolbox.createChestForAddress(to); - await demoUsd.mintFromFaucetInto(100, fromVaultId); + await demoUsd.mintFromFaucetInto(100, fromChestId); const [{ balance: fromBalanceBefore }, { balance: toBalanceBefore }] = await Promise.all([ - toolbox.getBalance(fromVaultId, demoUsd.demoUsdAssetType), - toolbox.getBalance(toVaultId, demoUsd.demoUsdAssetType), + toolbox.getBalance(fromChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(toChestId, demoUsd.demoUsdAssetType), ]); expect(Number(fromBalanceBefore.balance)).toBe(100 * 1_000_000); @@ -125,15 +125,15 @@ describe.concurrent( await toolbox.executeTransaction(tx); const [{ balance: fromBalanceAfter }, { balance: toBalanceAfter }] = await Promise.all([ - toolbox.getBalance(fromVaultId, demoUsd.demoUsdAssetType), - toolbox.getBalance(toVaultId, demoUsd.demoUsdAssetType), + toolbox.getBalance(fromChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(toChestId, demoUsd.demoUsdAssetType), ]); expect(Number(fromBalanceAfter.balance)).toBe(0); expect(Number(toBalanceAfter.balance)).toBe(100 * 1_000_000); }); - it('Should be able to create the recipient vault if it does not exist ahead of time', async () => { + it('Should be able to create the recipient chest if it does not exist ahead of time', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createRule(); @@ -141,15 +141,15 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromVaultId = toolbox.client.pas.deriveVaultAddress(from); - const toVaultId = toolbox.client.pas.deriveVaultAddress(to); + const fromChestId = toolbox.client.pas.deriveChestAddress(from); + const toChestId = toolbox.client.pas.deriveChestAddress(to); - await demoUsd.mintFromFaucetInto(100, fromVaultId); - await toolbox.createVaultForAddress(from); + await demoUsd.mintFromFaucetInto(100, fromChestId); + await toolbox.createChestForAddress(from); await expect( toolbox.client.core.getObject({ - objectId: toVaultId, + objectId: toChestId, }), ).rejects.toThrowError('not found'); @@ -167,13 +167,13 @@ describe.concurrent( // Object should now exist after the first transfer. const responseAfter = await toolbox.client.core.getObject({ - objectId: toVaultId, + objectId: toChestId, }); expect(responseAfter.object).toBeDefined(); }); - it('Should deduplicate vault creation when multiple intents reference the same non-existent vaults', async () => { + it('Should deduplicate chest creation when multiple intents reference the same non-existent chests', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createRule(); @@ -182,37 +182,37 @@ describe.concurrent( const sender = toolbox.address(); const receiver = normalizeSuiAddress('0xB2'); - const senderVaultId = toolbox.client.pas.deriveVaultAddress(sender); - const receiverVaultId = toolbox.client.pas.deriveVaultAddress(receiver); + const senderChestId = toolbox.client.pas.deriveChestAddress(sender); + const receiverChestId = toolbox.client.pas.deriveChestAddress(receiver); - // Verify neither vault exists. - await expect(toolbox.client.core.getObject({ objectId: senderVaultId })).rejects.toThrowError( + // Verify neither chest exists. + await expect(toolbox.client.core.getObject({ objectId: senderChestId })).rejects.toThrowError( 'not found', ); await expect( - toolbox.client.core.getObject({ objectId: receiverVaultId }), + toolbox.client.core.getObject({ objectId: receiverChestId }), ).rejects.toThrowError('not found'); - // Mint funds directly into the sender vault's address (balance::send_funds - // works even before the vault object exists). - await demoUsd.mintFromFaucetInto(200, senderVaultId); + // Mint funds directly into the sender chest's address (balance::send_funds + // works even before the chest object exists). + await demoUsd.mintFromFaucetInto(200, senderChestId); // Build a single PTB that: - // 1. Implicitly creates the sender vault (via vaultForAddress) + // 1. Implicitly creates the sender chest (via chestForAddress) // 2. Has an intermediate non-PAS moveCall (a no-op) - // 3. Transfers 50 DEMO_USD from sender -> receiver (receiver vault created implicitly) + // 3. Transfers 50 DEMO_USD from sender -> receiver (receiver chest created implicitly) // 4. Has another intermediate non-PAS moveCall - // 5. Transfers another 50 DEMO_USD from sender -> receiver (same vaults, no re-creation) + // 5. Transfers another 50 DEMO_USD from sender -> receiver (same chests, no re-creation) const tx = new Transaction(); - // (1) vaultForAddress for sender -- forces implicit creation - tx.add(toolbox.client.pas.tx.vaultForAddress(sender)); + // (1) chestForAddress for sender -- forces implicit creation + tx.add(toolbox.client.pas.tx.chestForAddress(sender)); // (2) Intermediate command: a harmless moveCall (merge empty split back into gas) const split1 = tx.splitCoins(tx.gas, [tx.pure.u64(0)]); tx.mergeCoins(tx.gas, [split1]); - // (3) First transfer: sender -> receiver (receiver vault does not exist) + // (3) First transfer: sender -> receiver (receiver chest does not exist) tx.add( toolbox.client.pas.tx.transferFunds({ from: sender, @@ -226,7 +226,7 @@ describe.concurrent( const split2 = tx.splitCoins(tx.gas, [tx.pure.u64(0)]); tx.mergeCoins(tx.gas, [split2]); - // (5) Second transfer: sender -> receiver (both vaults already created in this PTB) + // (5) Second transfer: sender -> receiver (both chests already created in this PTB) tx.add( toolbox.client.pas.tx.transferFunds({ from: sender, @@ -238,18 +238,18 @@ describe.concurrent( await toolbox.executeTransaction(tx); - // Verify both vaults now exist. + // Verify both chests now exist. const [senderObj, receiverObj] = await Promise.all([ - toolbox.client.core.getObject({ objectId: senderVaultId }), - toolbox.client.core.getObject({ objectId: receiverVaultId }), + toolbox.client.core.getObject({ objectId: senderChestId }), + toolbox.client.core.getObject({ objectId: receiverChestId }), ]); expect(senderObj.object).toBeDefined(); expect(receiverObj.object).toBeDefined(); // Verify balances: sender started with 200, transferred 50+50 = 100. const [{ balance: senderBalance }, { balance: receiverBalance }] = await Promise.all([ - toolbox.getBalance(senderVaultId, demoUsd.demoUsdAssetType), - toolbox.getBalance(receiverVaultId, demoUsd.demoUsdAssetType), + toolbox.getBalance(senderChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(receiverChestId, demoUsd.demoUsdAssetType), ]); expect(Number(senderBalance.balance)).toBe(100 * 1_000_000); @@ -263,11 +263,11 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x3'); - const fromVaultId = toolbox.client.pas.deriveVaultAddress(from); + const fromChestId = toolbox.client.pas.deriveChestAddress(from); - await toolbox.createVaultForAddress(from); - await toolbox.createVaultForAddress(to); - await demoUsd.mintFromFaucetInto(15_000, fromVaultId); + await toolbox.createChestForAddress(from); + await toolbox.createChestForAddress(to); + await demoUsd.mintFromFaucetInto(15_000, fromChestId); const tx = new Transaction(); tx.add( @@ -286,16 +286,16 @@ describe.concurrent( ); }); - it('self-transfer is rejected (same vault cannot be borrowed mutably twice)', async () => { + it('self-transfer is rejected (same chest cannot be borrowed mutably twice)', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createRule(); const addr = toolbox.address(); - const vaultId = toolbox.client.pas.deriveVaultAddress(addr); + const chestId = toolbox.client.pas.deriveChestAddress(addr); - await toolbox.createVaultForAddress(addr); - await demoUsd.mintFromFaucetInto(10, vaultId); + await toolbox.createChestForAddress(addr); + await demoUsd.mintFromFaucetInto(10, chestId); const tx = new Transaction(); tx.add( @@ -309,14 +309,14 @@ describe.concurrent( const resp = await simulateFailingTransaction(toolbox, tx); expect(resp.FailedTransaction).toBeDefined(); - // Same vault passed as both &mut sender and &mut receiver -- Move rejects + // Same chest passed as both &mut sender and &mut receiver -- Move rejects // this before the approval function even runs. expect(resp.FailedTransaction!.effects.status.error!.message).toContain( 'InvalidReferenceArgument', ); }); - it('Should fail to transfer between vaults, if there are not enough funds in the source vault', async () => { + it('Should fail to transfer between chests, if there are not enough funds in the source chest', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createRule(); @@ -324,8 +324,8 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - await toolbox.createVaultForAddress(from); - await toolbox.createVaultForAddress(to); + await toolbox.createChestForAddress(from); + await toolbox.createChestForAddress(to); const transaction = new Transaction(); transaction.add( @@ -358,11 +358,11 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x3'); - const fromVaultId = toolbox.client.pas.deriveVaultAddress(from); + const fromChestId = toolbox.client.pas.deriveChestAddress(from); - await toolbox.createVaultForAddress(from); - await toolbox.createVaultForAddress(to); - await demoUsd.mintFromFaucetInto(15_000, fromVaultId); + await toolbox.createChestForAddress(from); + await toolbox.createChestForAddress(to); + await demoUsd.mintFromFaucetInto(15_000, fromChestId); await demoUsd.upgradeToV2(); @@ -378,7 +378,7 @@ describe.concurrent( await toolbox.executeTransaction(tx); const { balance } = await toolbox.getBalance( - toolbox.client.pas.deriveVaultAddress(to), + toolbox.client.pas.deriveChestAddress(to), demoUsd.demoUsdAssetType, ); expect(Number(balance.balance)).toBe(15_000 * 1_000_000); @@ -396,13 +396,13 @@ describe.concurrent( const sender = toolbox.address(); const receiver = normalizeSuiAddress('0xB3'); - const senderVaultId = toolbox.client.pas.deriveVaultAddress(sender); - const receiverVaultId = toolbox.client.pas.deriveVaultAddress(receiver); + const senderChestId = toolbox.client.pas.deriveChestAddress(sender); + const receiverChestId = toolbox.client.pas.deriveChestAddress(receiver); - await asset1.mintFromFaucetInto(500, senderVaultId); - await asset2.mintFromFaucetInto(800, senderVaultId); + await asset1.mintFromFaucetInto(500, senderChestId); + await asset2.mintFromFaucetInto(800, senderChestId); - // --- First PTB: transfers both asset types, implicitly creates receiver vault --- + // --- First PTB: transfers both asset types, implicitly creates receiver chest --- const tx1 = new Transaction(); tx1.add( toolbox.client.pas.tx.transferFunds({ @@ -422,16 +422,16 @@ describe.concurrent( ); await toolbox.executeTransaction(tx1); - const receiverObj = await toolbox.client.core.getObject({ objectId: receiverVaultId }); + const receiverObj = await toolbox.client.core.getObject({ objectId: receiverChestId }); expect(receiverObj.object).toBeDefined(); await expectBalances(toolbox, [ - { vault: senderVaultId, asset: asset1.demoUsdAssetType, amount: 380 }, - { vault: senderVaultId, asset: asset2.demoUsdAssetType, amount: 450 }, - { vault: receiverVaultId, asset: asset1.demoUsdAssetType, amount: 120 }, - { vault: receiverVaultId, asset: asset2.demoUsdAssetType, amount: 350 }, + { chest: senderChestId, asset: asset1.demoUsdAssetType, amount: 380 }, + { chest: senderChestId, asset: asset2.demoUsdAssetType, amount: 450 }, + { chest: receiverChestId, asset: asset1.demoUsdAssetType, amount: 120 }, + { chest: receiverChestId, asset: asset2.demoUsdAssetType, amount: 350 }, ]); - // --- Second PTB: both vaults already exist, different amounts --- + // --- Second PTB: both chests already exist, different amounts --- const tx2 = new Transaction(); tx2.add( toolbox.client.pas.tx.transferFunds({ @@ -452,10 +452,10 @@ describe.concurrent( await toolbox.executeTransaction(tx2); await expectBalances(toolbox, [ - { vault: senderVaultId, asset: asset1.demoUsdAssetType, amount: 300 }, - { vault: senderVaultId, asset: asset2.demoUsdAssetType, amount: 300 }, - { vault: receiverVaultId, asset: asset1.demoUsdAssetType, amount: 200 }, - { vault: receiverVaultId, asset: asset2.demoUsdAssetType, amount: 500 }, + { chest: senderChestId, asset: asset1.demoUsdAssetType, amount: 300 }, + { chest: senderChestId, asset: asset2.demoUsdAssetType, amount: 300 }, + { chest: receiverChestId, asset: asset1.demoUsdAssetType, amount: 200 }, + { chest: receiverChestId, asset: asset2.demoUsdAssetType, amount: 500 }, ]); }); @@ -466,11 +466,11 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromVaultId = toolbox.client.pas.deriveVaultAddress(from); + const fromChestId = toolbox.client.pas.deriveChestAddress(from); - await toolbox.createVaultForAddress(from); - await toolbox.createVaultForAddress(to); - await demoUsd.mintFromFaucetInto(10, fromVaultId); + await toolbox.createChestForAddress(from); + await toolbox.createChestForAddress(to); + await demoUsd.mintFromFaucetInto(10, fromChestId); await demoUsd.upgradeToV2(); diff --git a/sdk/pas/test/e2e/e2e.shared.test.ts b/sdk/pas/test/e2e/e2e.shared.test.ts index b595659..5d545a1 100644 --- a/sdk/pas/test/e2e/e2e.shared.test.ts +++ b/sdk/pas/test/e2e/e2e.shared.test.ts @@ -3,7 +3,7 @@ import { Transaction } from '@mysten/sui/transactions'; import { normalizeSuiAddress } from '@mysten/sui/utils'; import { beforeAll, describe, expect, it } from 'vitest'; -import { Vault } from '../../src/contracts/pas/vault.js'; +import { Chest } from '../../src/contracts/pas/chest.js'; import { DemoUsdTestHelpers } from './demoUsd.ts'; import { setupToolbox, TestToolbox } from './setup.ts'; @@ -22,9 +22,9 @@ describe('e2e tests with shared PAS package (all tests run in the same PAS packa const keypair = Ed25519Keypair.generate(); const address = keypair.getPublicKey().toSuiAddress(); - await toolbox.createVaultForAddress(address); - const vaultId = toolbox.client.pas.deriveVaultAddress(address); - await demoUsd.mintFromFaucetInto(100, vaultId); + await toolbox.createChestForAddress(address); + const chestId = toolbox.client.pas.deriveChestAddress(address); + await demoUsd.mintFromFaucetInto(100, chestId); const tx = new Transaction(); tx.add( @@ -46,21 +46,21 @@ describe('e2e tests with shared PAS package (all tests run in the same PAS packa ).rejects.toThrowError('No required approvals found for action'); }); - it('derivations work as expected for vaults', async () => { - const vaultObjectId = toolbox.client.pas.deriveVaultAddress(toolbox.address()); - await toolbox.createVaultForAddress(toolbox.address()); + it('derivations work as expected for chests', async () => { + const chestObjectId = toolbox.client.pas.deriveChestAddress(toolbox.address()); + await toolbox.createChestForAddress(toolbox.address()); - const { object: vaultObject } = await toolbox.client.core.getObject({ - objectId: vaultObjectId, + const { object: chestObject } = await toolbox.client.core.getObject({ + objectId: chestObjectId, include: { content: true }, }); - expect(vaultObject).toBeDefined(); + expect(chestObject).toBeDefined(); - const parsed = Vault.parse(vaultObject.content!); + const parsed = Chest.parse(chestObject.content!); expect(normalizeSuiAddress(parsed.owner)).toBe(normalizeSuiAddress(toolbox.address())); - expect(vaultObject.type).toBe( - `${toolbox.client.pas.getPackageConfig().packageId}::vault::Vault`, + expect(chestObject.type).toBe( + `${toolbox.client.pas.getPackageConfig().packageId}::chest::Chest`, ); }); diff --git a/sdk/pas/test/e2e/setup.ts b/sdk/pas/test/e2e/setup.ts index 01e3697..a63646c 100644 --- a/sdk/pas/test/e2e/setup.ts +++ b/sdk/pas/test/e2e/setup.ts @@ -107,10 +107,10 @@ export class TestToolbox { return executeTransaction(this, tx); } - // Creates a vault for a given address. - async createVaultForAddress(address: string) { + // Creates a chest for a given address. + async createChestForAddress(address: string) { const tx = new Transaction(); - tx.add(this.client.pas.tx.vaultForAddress(address)); + tx.add(this.client.pas.tx.chestForAddress(address)); return this.executeTransaction(tx); } diff --git a/sdk/pas/test/unit/derivation.test.ts b/sdk/pas/test/unit/derivation.test.ts index 25aa1b0..72dc9ca 100644 --- a/sdk/pas/test/unit/derivation.test.ts +++ b/sdk/pas/test/unit/derivation.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'; -import { deriveRuleAddress, deriveVaultAddress } from '../../src/derivation.js'; +import { deriveChestAddress, deriveRuleAddress } from '../../src/derivation.js'; import type { PASPackageConfig } from '../../src/types.js'; describe('PAS Object Derivation', () => { @@ -12,48 +12,48 @@ describe('PAS Object Derivation', () => { namespaceId: '0xabc', }; - describe('deriveVaultAddress', () => { - it('should derive vault address for owner 0x456', () => { - const vaultId = deriveVaultAddress('0x456', packageConfig); - expect(vaultId).toMatchInlineSnapshot( + describe('deriveChestAddress', () => { + it('should derive chest address for owner 0x456', () => { + const chestId = deriveChestAddress('0x456', packageConfig); + expect(chestId).toMatchInlineSnapshot( `"0x8712c77726f5c0927363764d6fd6ec64fb03becb51228bfcb2017442b6c30b62"`, ); }); - it('should derive vault address for owner 0x789', () => { - const vaultId = deriveVaultAddress('0x789', packageConfig); - expect(vaultId).toMatchInlineSnapshot( + it('should derive chest address for owner 0x789', () => { + const chestId = deriveChestAddress('0x789', packageConfig); + expect(chestId).toMatchInlineSnapshot( `"0x36379f73c885824bd00cf8e441464aa7a3ccd0624c1c34fd526ed7db1f83a116"`, ); }); - it('should derive vault address for different namespace', () => { + it('should derive chest address for different namespace', () => { const config = { ...packageConfig, namespaceId: '0xdef' }; - const vaultId = deriveVaultAddress('0x456', config); - expect(vaultId).toMatchInlineSnapshot( + const chestId = deriveChestAddress('0x456', config); + expect(chestId).toMatchInlineSnapshot( `"0xa378d4ccc977bbb997618a32c4bbe8cc55a67551870f2574626fd624e1b3cfb7"`, ); }); it('should normalize addresses correctly', () => { - const vaultId1 = deriveVaultAddress('0x1', packageConfig); - const vaultId2 = deriveVaultAddress( + const chestId1 = deriveChestAddress('0x1', packageConfig); + const chestId2 = deriveChestAddress( '0x0000000000000000000000000000000000000000000000000000000000000001', packageConfig, ); - expect(vaultId1).toBe(vaultId2); - expect(vaultId1).toMatchInlineSnapshot( + expect(chestId1).toBe(chestId2); + expect(chestId1).toMatchInlineSnapshot( `"0xe5dd472028385358d7727a799555e42f43858c7621a84473e0f5384cda737ed6"`, ); }); - it('should derive vault for object owner', () => { - const vaultId = deriveVaultAddress( + it('should derive chest for object owner', () => { + const chestId = deriveChestAddress( '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', packageConfig, ); - expect(vaultId).toMatchInlineSnapshot( + expect(chestId).toMatchInlineSnapshot( `"0xf29869e74858befbd65b5b03338d0b1f4855bb7eeb6b37b5559879f461930114"`, ); }); From 0276582505dfb6c501e621cf4c0a1ea2eea21d44 Mon Sep 17 00:00:00 2001 From: Manos Liolios Date: Thu, 19 Feb 2026 13:24:29 +0200 Subject: [PATCH 2/3] fmt --- packages/pas/tests/chest_auth_tests.move | 2 +- packages/pas/tests/versioning_tests.move | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pas/tests/chest_auth_tests.move b/packages/pas/tests/chest_auth_tests.move index e9c51a7..3ae6bed 100644 --- a/packages/pas/tests/chest_auth_tests.move +++ b/packages/pas/tests/chest_auth_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::chest_auth_tests; -use pas::{e2e::{test_tx, A}, chest::{Self, Chest}}; +use pas::{chest::{Self, Chest}, e2e::{test_tx, A}}; use std::unit_test::{assert_eq, destroy}; use sui::test_scenario::return_shared; diff --git a/packages/pas/tests/versioning_tests.move b/packages/pas/tests/versioning_tests.move index d6b7341..cef8a68 100644 --- a/packages/pas/tests/versioning_tests.move +++ b/packages/pas/tests/versioning_tests.move @@ -2,9 +2,9 @@ module pas::versioning_tests; use pas::{ + chest, e2e::{package_id, test_tx, A}, namespace::{Self, Namespace}, - chest, versioning::breaking_version }; use ptb::ptb::Command; From 55cd34214d8f12ca2799bbf3b5aa6a9f1ad5f942 Mon Sep 17 00:00:00 2001 From: Manos Liolios Date: Thu, 19 Feb 2026 13:25:27 +0200 Subject: [PATCH 3/3] more fmt --- packages/pas/tests/clawback_tests.move | 4 ++-- packages/pas/tests/e2e.move | 2 +- packages/pas/tests/rule_setup_tests.move | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/pas/tests/clawback_tests.move b/packages/pas/tests/clawback_tests.move index df7bdf0..2194541 100644 --- a/packages/pas/tests/clawback_tests.move +++ b/packages/pas/tests/clawback_tests.move @@ -2,10 +2,10 @@ module pas::clawback_tests; use pas::{ + chest, clawback_funds, e2e::{test_tx, a_witness, A, b_witness, B, AWitness}, - rule::RuleCap, - chest + rule::RuleCap }; use std::{type_name, unit_test::assert_eq}; use sui::balance; diff --git a/packages/pas/tests/e2e.move b/packages/pas/tests/e2e.move index 1f952de..ee89cee 100644 --- a/packages/pas/tests/e2e.move +++ b/packages/pas/tests/e2e.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::e2e; -use pas::{rule::{Self, RuleCap}, transfer_funds, unlock_funds, chest::{Self, Chest}}; +use pas::{chest::{Self, Chest}, rule::{Self, RuleCap}, transfer_funds, unlock_funds}; use std::{type_name, unit_test::{assert_eq, destroy}}; use sui::{balance::{Self, send_funds}, sui::SUI, test_scenario::return_shared, vec_set}; diff --git a/packages/pas/tests/rule_setup_tests.move b/packages/pas/tests/rule_setup_tests.move index 4fe624b..0f31956 100644 --- a/packages/pas/tests/rule_setup_tests.move +++ b/packages/pas/tests/rule_setup_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::rule_setup_tests; -use pas::{e2e::{test_tx, A}, rule::RuleCap, transfer_funds, chest}; +use pas::{chest, e2e::{test_tx, A}, rule::RuleCap, transfer_funds}; use sui::balance; public struct InvalidActionApproval() has drop;