From 22d422a43b8e8a696654a989f5a185ea8e4c5763 Mon Sep 17 00:00:00 2001 From: Manos Liolios Date: Wed, 11 Mar 2026 13:21:59 +0200 Subject: [PATCH 1/2] Rename chest to account --- README.md | 24 +-- .../pas/sources/{chest.move => account.move} | 116 +++++------ packages/pas/sources/keys.move | 6 +- packages/pas/sources/namespace.move | 18 +- .../pas/sources/requests/clawback_funds.move | 12 +- packages/pas/sources/requests/send_funds.move | 30 +-- .../pas/sources/requests/unlock_funds.move | 14 +- ...uth_tests.move => account_auth_tests.move} | 58 +++--- packages/pas/tests/clawback_tests.move | 24 +-- packages/pas/tests/e2e.move | 172 ++++++++-------- packages/pas/tests/policy_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 +-- .../contracts/pas/{chest.ts => account.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/send_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, 608 insertions(+), 608 deletions(-) rename packages/pas/sources/{chest.move => account.move} (55%) rename packages/pas/tests/{chest_auth_tests.move => account_auth_tests.move} (50%) rename sdk/pas/src/contracts/pas/{chest.ts => account.ts} (85%) diff --git a/README.md b/README.md index 8319e3c..9a3979d 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 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) +1. Each address has a single account (derived address, with easy discoverability). Objects can own accounts as well. This enables with account abstractions / defi protocols implementations +2. Account uses address (object) balances, so RPCs work out of the box (wallet just treats the account address like a normal one). Wallets/explorers needs to query for the derived account address to get balances. +3. Balances can only move from account to account (either by safe account-to-account deposits, or deriving the recipient with `unsafe_` calls) 4. When a transfer is initiated, a `SendFunds` 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 (chests are shared and a clawback can be initiated using the issuer's witness). +5. Clawback is available (accounts are shared and a clawback can be initiated using the issuer's witness). -(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). +(To be added: Issuers can attach "metadata" to user's Accounts (such as `KYC` stamps or AML stamps they issue), which they can then check on their transfer functions to restrict movement. Since accounts are shared, issuers can revoke these stamps at any moment). ## Key Features -- **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 +- **Permissioned Transfers**: All transfers must go through accounts and be approved by custom transfer rules +- **Account-Based Architecture**: Tokens can only be held in accounts, with automatic balance tracking - **Flexible Policies 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. **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 policy +2. **Account Creation**: Accounts are derived for each address that needs to hold tokens +3. **Transfers**: Initiated from source account, creating a transfer request that must be resolved by the policy 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 chest per user** which holds the balances of the user -- **No indexing required** - chest and policy addresses are deterministically computable -- **One query** to see all user balances via dynamic fields on their chest +- **Single account per user** which holds the balances of the user +- **No indexing required** - account and policy addresses are deterministically computable +- **One query** to see all user balances via dynamic fields on their account ### Easy Resolution diff --git a/packages/pas/sources/chest.move b/packages/pas/sources/account.move similarity index 55% rename from packages/pas/sources/chest.move rename to packages/pas/sources/account.move index fe8c31d..7e41057 100644 --- a/packages/pas/sources/chest.move +++ b/packages/pas/sources/account.move @@ -1,5 +1,5 @@ -/// Chest logic -module pas::chest; +/// Account logic +module pas::account; 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 = 0)] -const ENotOwner: vector = b"The owner is not valid for the chest."; +const ENotOwner: vector = b"The owner is not valid for the account."; #[error(code = 1)] -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 { +const EAccountAlreadyExists: vector = b"The account already exists."; + +/// There is only one Account per address (guaranteed by derived objects). +/// - Balances can only be transferred from Account A to Account B. +/// - Accounts are shared by default. +/// - Accounts creation is permission-less +/// - A `UID` (object) can also own a account +public struct Account has key { id: UID, - /// The owner of the chest (address or object) + /// The owner of the account (address or object) owner: address, - /// The ID of the namespace that created this chest. + /// The ID of the namespace that created this account. /// 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 Chest has key { /// `UID` and `ctx.sender()` (keeping a single API for both). public struct Auth(address) has drop; -/// 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); +/// Create a new account for `owner`. This is a permission-less action. +public fun create(namespace: &mut Namespace, owner: address): Account { + assert!(!namespace.account_exists(owner), EAccountAlreadyExists); let versioning = namespace.versioning(); versioning.assert_is_valid_version(); - Chest { - id: derived_object::claim(namespace.uid_mut(), keys::chest_key(owner)), + Account { + id: derived_object::claim(namespace.uid_mut(), keys::account_key(owner)), owner, namespace_id: object::id(namespace), versioning, } } -/// 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); +/// The only way to finalize the TX is by sharing the account. +/// All accounts are shared by default. +public fun share(account: Account) { + transfer::share_object(account); } -/// Create and share a chest in a single step. +/// Create and share a account 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 Policy within the system, or /// if there's a special case where an issuer allows balances to flow out of the system. public fun unlock_balance( - chest: &mut Chest, + account: &mut Account, auth: &Auth, amount: u64, _ctx: &mut TxContext, ): Request>> { - auth.assert_is_valid_for_chest!(chest); - chest.versioning.assert_is_valid_version(); - unlock_funds::new(chest.owner, chest.id.to_inner(), chest.withdraw_balance(amount)) + auth.assert_is_valid_for_account!(account); + account.versioning.assert_is_valid_version(); + unlock_funds::new(account.owner, account.id.to_inner(), account.withdraw_balance(amount)) } -/// Initiate a transfer from chest A to chest B. +/// Initiate a transfer from account A to account B. public fun send_balance( - from: &mut Chest, + from: &mut Account, auth: &Auth, - to: &Chest, + to: &Account, amount: u64, _ctx: &mut TxContext, ): Request>> { - auth.assert_is_valid_for_chest!(from); + auth.assert_is_valid_for_account!(from); from.versioning.assert_is_valid_version(); from.internal_send_balance(to.owner, amount) } @@ -97,7 +97,7 @@ public fun send_balance( /// /// This can only ever finalize if clawback is enabled in the policy. public fun clawback_balance( - from: &mut Chest, + from: &mut Account, amount: u64, _ctx: &mut TxContext, ): Request>> { @@ -105,19 +105,19 @@ public fun clawback_balance( clawback_funds::new(from.owner, from.id.to_inner(), from.withdraw_balance(amount)) } -/// Transfer `amount` from chest to an address. This unlocks transfers to a chest before it has been created. +/// Transfer `amount` from account to an address. This unlocks transfers to a account before it has been created. /// /// It's marked as `unsafe_` as it's easy to accidentally pick the wrong recipient address. public fun unsafe_send_balance( - from: &mut Chest, + from: &mut Account, auth: &Auth, - // Recipients should always be the wallet or object address, not the chest ID. + // Recipients should always be the wallet or object address, not the account 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_chest!(from); + auth.assert_is_valid_for_account!(from); from.versioning.assert_is_valid_version(); from.internal_send_balance(recipient_address, amount) } @@ -127,59 +127,59 @@ public fun new_auth(ctx: &TxContext): Auth { Auth(ctx.sender()) } -/// Generate an ownership proof from a `UID` object, to allow objects to own chests. +/// Generate an ownership proof from a `UID` object, to allow objects to own accounts. /// `&mut UID` is intentional — it serves as proof of ownership over the object. public fun new_auth_as_object(uid: &mut UID): Auth { Auth(uid.to_inner().to_address()) } -public fun owner(chest: &Chest): address { - chest.owner +public fun owner(account: &Account): address { + account.owner } -public fun deposit_balance(chest: &Chest, balance: Balance) { - chest.versioning.assert_is_valid_version(); - balance::send_funds(balance, object::id(chest).to_address()); +public fun deposit_balance(account: &Account, balance: Balance) { + account.versioning.assert_is_valid_version(); + balance::send_funds(balance, object::id(account).to_address()); } /// Permission-less operation to bring versioning up-to-date with the namespace. -public fun sync_versioning(chest: &mut Chest, namespace: &Namespace) { - chest.versioning = namespace.versioning(); +public fun sync_versioning(account: &mut Account, namespace: &Namespace) { + account.versioning = namespace.versioning(); } -public(package) fun withdraw_balance(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 withdraw_balance(account: &mut Account, amount: u64): Balance { + account.versioning.assert_is_valid_version(); + balance::redeem_funds(account.id.withdraw_funds_from_object(amount)) } -public(package) fun versioning(chest: &Chest): Versioning { - chest.versioning +public(package) fun versioning(account: &Account): Versioning { + account.versioning } -/// Verify that the ownership proof matches the chests owner. -macro fun assert_is_valid_for_chest($proof: &Auth, $chest: &Chest) { +/// Verify that the ownership proof matches the accounts owner. +macro fun assert_is_valid_for_account($proof: &Auth, $account: &Account) { let proof = $proof; - let chest = $chest; - assert!(&proof.0 == &chest.owner, ENotOwner); + let account = $account; + assert!(&proof.0 == &account.owner, ENotOwner); } -/// The internal implementation for transferring `amount` from Chest towards another address. +/// The internal implementation for transferring `amount` from Account towards another address. /// -/// INTERNAL WARNING: Callers must verify that `to` is the user address, NOT the chest address. +/// INTERNAL WARNING: Callers must verify that `to` is the user address, NOT the account address. /// Failure to do so can cause assets to move out of the closed loop, breaking the system assurances fun internal_send_balance( - from: &mut Chest, + from: &mut Account, to: address, amount: u64, ): Request>> { let funds = from.withdraw_balance(amount); - let recipient_chest_id = namespace::chest_address_from_id(from.namespace_id, to); + let recipient_account_id = namespace::account_address_from_id(from.namespace_id, to); send_funds::new( from.owner, to, from.id.to_inner(), - recipient_chest_id.to_id(), + recipient_account_id.to_id(), funds, ) } diff --git a/packages/pas/sources/keys.move b/packages/pas/sources/keys.move index ab2bfd5..eedaa96 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 `Policy` from the namespace public struct PolicyKey() has copy, drop, store; -/// Key for deriving `Chest` from the namespace -public struct ChestKey(address) has copy, drop, store; +/// Key for deriving `Account` from the namespace +public struct AccountKey(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 policy_key(): PolicyKey { PolicyKey() } -public(package) fun chest_key(owner: address): ChestKey { ChestKey(owner) } +public(package) fun account_key(owner: address): AccountKey { AccountKey(owner) } public(package) fun template_key(): TemplateKey { TemplateKey() } diff --git a/packages/pas/sources/namespace.move b/packages/pas/sources/namespace.move index c621780..d8c2ebd 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. Chests +/// 1. Accounts /// 2. Policies /// ... 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 chests, policies, etc. +/// The namespace is only used for address derivation of accounts, policies, etc. /// /// Namespace is a singleton -- there's one global version for it. public struct Namespace has key { @@ -79,17 +79,17 @@ public fun policy_address(namespace: &Namespace): address { derived_object::derive_address(namespace.id.to_inner(), keys::policy_key()) } -public fun chest_exists(namespace: &Namespace, owner: address): bool { - derived_object::exists(&namespace.id, keys::chest_key(owner)) +public fun account_exists(namespace: &Namespace, owner: address): bool { + derived_object::exists(&namespace.id, keys::account_key(owner)) } -public fun chest_address(namespace: &Namespace, owner: address): address { - derived_object::derive_address(namespace.id.to_inner(), keys::chest_key(owner)) +public fun account_address(namespace: &Namespace, owner: address): address { + derived_object::derive_address(namespace.id.to_inner(), keys::account_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)) +// Given the name space ID, calculate the account address. +public(package) fun account_address_from_id(namespace_id: ID, owner: address): address { + derived_object::derive_address(namespace_id, keys::account_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 07dbb64..1ad2051 100644 --- a/packages/pas/sources/requests/clawback_funds.move +++ b/packages/pas/sources/requests/clawback_funds.move @@ -7,17 +7,17 @@ const EClawbackNotAllowed: vector = b"Attempted to clawback tokens when clawback is not enabled for this policy."; public struct ClawbackFunds { - /// `owner` is the wallet OR object address, NOT the chest address + /// `owner` is the wallet OR object address, NOT the account address owner: address, - /// The ID of the chest the funds are coming from - chest_id: ID, + /// The ID of the account the funds are coming from + account_id: ID, /// The balance that is being clawed back. funds: T, } public fun owner(request: &ClawbackFunds): address { request.owner } -public fun chest_id(request: &ClawbackFunds): ID { request.chest_id } +public fun account_id(request: &ClawbackFunds): ID { request.account_id } public fun funds(request: &ClawbackFunds): &T { &request.funds } @@ -36,8 +36,8 @@ public fun resolve(request: Request>, policy: &Policy public(package) fun new( owner: address, - chest_id: ID, + account_id: ID, funds: T, ): Request> { - request::new(ClawbackFunds { owner, chest_id, funds }) + request::new(ClawbackFunds { owner, account_id, funds }) } diff --git a/packages/pas/sources/requests/send_funds.move b/packages/pas/sources/requests/send_funds.move index 984c1d5..64288b9 100644 --- a/packages/pas/sources/requests/send_funds.move +++ b/packages/pas/sources/requests/send_funds.move @@ -18,14 +18,14 @@ use sui::balance::{Self, Balance}; /// - Handle dividends/distributions /// - Implement any jurisdiction-specific rules public struct SendFunds { - /// `sender` is the wallet OR object address, NOT the chest address + /// `sender` is the wallet OR object address, NOT the account address sender: address, - /// `recipient` is the wallet OR object address, NOT the chest address + /// `recipient` is the wallet OR object address, NOT the account address recipient: address, - /// 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 ID of the account the funds are coming from + sender_account_id: ID, + /// The ID of the account the funds are going to + recipient_account_id: ID, /// The balance being transferred funds: T, } @@ -34,10 +34,10 @@ public fun sender(request: &SendFunds): address { request.sender } public fun recipient(request: &SendFunds): address { request.recipient } -public fun sender_chest_id(request: &SendFunds): ID { request.sender_chest_id } +public fun sender_account_id(request: &SendFunds): ID { request.sender_account_id } -public fun recipient_chest_id(request: &SendFunds): ID { - request.recipient_chest_id +public fun recipient_account_id(request: &SendFunds): ID { + request.recipient_account_id } public fun funds(request: &SendFunds): &T { &request.funds } @@ -45,15 +45,15 @@ public fun funds(request: &SendFunds): &T { &request.funds } public(package) fun new( sender: address, recipient: address, - sender_chest_id: ID, - recipient_chest_id: ID, + sender_account_id: ID, + recipient_account_id: ID, funds: T, ): Request> { request::new(SendFunds { sender, recipient, - sender_chest_id, - recipient_chest_id, + sender_account_id, + recipient_account_id, funds, }) } @@ -66,6 +66,6 @@ public fun resolve_balance( policy.versioning().assert_is_valid_version(); let data = request.resolve(policy.required_approvals(send_funds_action())); - let SendFunds { funds, recipient_chest_id, .. } = data; - balance::send_funds(funds, recipient_chest_id.to_address()); + let SendFunds { funds, recipient_account_id, .. } = data; + balance::send_funds(funds, recipient_account_id.to_address()); } diff --git a/packages/pas/sources/requests/unlock_funds.move b/packages/pas/sources/requests/unlock_funds.move index a04c2bf..9335747 100644 --- a/packages/pas/sources/requests/unlock_funds.move +++ b/packages/pas/sources/requests/unlock_funds.move @@ -19,17 +19,17 @@ const ECannotResolveManagedAssets: vector = /// by calling `policy::resolve_unlock_funds` /// 2. If the asset is not permissioned, it can be resolved by any address by calling `unlock_funds::resolve_unrestricted_balance` public struct UnlockFunds { - /// `owner` is the wallet OR object address, NOT the chest address + /// `owner` is the wallet OR object address, NOT the account address owner: address, - /// The ID of the chest the funds are coming from - chest_id: ID, + /// The ID of the account the funds are coming from + account_id: ID, /// The actual balance being transferred funds: T, } public fun owner(request: &UnlockFunds): address { request.owner } -public fun chest_id(request: &UnlockFunds): ID { request.chest_id } +public fun account_id(request: &UnlockFunds): ID { request.account_id } public fun funds(request: &UnlockFunds): &T { &request.funds } @@ -37,7 +37,7 @@ public fun funds(request: &UnlockFunds): &T { &request.funds } /// If a `Policy` 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 chest. +/// to withdraw if anyone transfers some to their account. public fun resolve_unrestricted_balance( request: Request>>, namespace: &Namespace, @@ -59,6 +59,6 @@ public fun resolve(request: Request>, policy: &Policy(owner: address, chest_id: ID, funds: T): Request> { - request::new(UnlockFunds { owner, chest_id, funds }) +public(package) fun new(owner: address, account_id: ID, funds: T): Request> { + request::new(UnlockFunds { owner, account_id, funds }) } diff --git a/packages/pas/tests/chest_auth_tests.move b/packages/pas/tests/account_auth_tests.move similarity index 50% rename from packages/pas/tests/chest_auth_tests.move rename to packages/pas/tests/account_auth_tests.move index 1fac77c..6b9c860 100644 --- a/packages/pas/tests/chest_auth_tests.move +++ b/packages/pas/tests/account_auth_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] -module pas::chest_auth_tests; +module pas::account_auth_tests; -use pas::{chest::{Self, Chest}, e2e::{test_tx, A}}; +use pas::{account::{Self, Account}, e2e::{test_tx, A}}; 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(); - chest::create_and_share(namespace, uid_address); + account::create_and_share(namespace, uid_address); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared(); + let mut account = scenario.take_shared(); - assert_eq!(chest.owner(), uid_address); - assert_eq!(object::id(&chest).to_address(), namespace.chest_address(uid_address)); + assert_eq!(account.owner(), uid_address); + assert_eq!(object::id(&account).to_address(), namespace.account_address(uid_address)); - let auth = chest::new_auth_as_object(&mut uid); + let auth = account::new_auth_as_object(&mut uid); - let transfer_request = chest.unsafe_send_balance( + let transfer_request = account.unsafe_send_balance( &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_chest_id(), - namespace.chest_address(uid_address).to_id(), + transfer_request.data().sender_account_id(), + namespace.account_address(uid_address).to_id(), ); assert_eq!( - transfer_request.data().recipient_chest_id(), - namespace.chest_address(@0x2).to_id(), + transfer_request.data().recipient_account_id(), + namespace.account_address(@0x2).to_id(), ); assert_eq!(transfer_request.data().funds().value(), 50); destroy(transfer_request); - return_shared(chest); + return_shared(account); uid.delete(); }); } -#[test, expected_failure(abort_code = ::pas::chest::ENotOwner)] -fun try_to_auth_to_another_owners_chest() { +#[test, expected_failure(abort_code = ::pas::account::ENotOwner)] +fun try_to_auth_to_another_owners_account() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - chest::create_and_share(namespace, @0x1); + account::create_and_share(namespace, @0x1); scenario.next_tx(@0x2); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let auth = chest::new_auth(scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); - let _transfer_request = chest.unsafe_send_balance( + let _transfer_request = account.unsafe_send_balance( &auth, @0x2, 50, @@ -79,17 +79,17 @@ fun try_to_auth_to_another_owners_chest() { }); } -#[test, expected_failure(abort_code = ::pas::chest::ENotOwner)] -fun try_to_auth_to_another_uid_chest() { +#[test, expected_failure(abort_code = ::pas::account::ENotOwner)] +fun try_to_auth_to_another_uid_account() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); + let mut account = account::create(namespace, @0x1); let mut uid = object::new(scenario.ctx()); - let auth = chest::new_auth_as_object(&mut uid); + let auth = account::new_auth_as_object(&mut uid); - let transfer_request = chest.unlock_balance( + let transfer_request = account.unlock_balance( &auth, 50, scenario.ctx(), @@ -99,12 +99,12 @@ fun try_to_auth_to_another_uid_chest() { }); } -#[test, expected_failure(abort_code = ::pas::chest::EChestAlreadyExists)] -fun try_to_create_chest_with_same_owner() { +#[test, expected_failure(abort_code = ::pas::account::EAccountAlreadyExists)] +fun try_to_create_account_with_same_owner() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - chest::create_and_share(namespace, @0x1); - chest::create_and_share(namespace, @0x1); + account::create_and_share(namespace, @0x1); + account::create_and_share(namespace, @0x1); abort }); } diff --git a/packages/pas/tests/clawback_tests.move b/packages/pas/tests/clawback_tests.move index 0673e14..289a358 100644 --- a/packages/pas/tests/clawback_tests.move +++ b/packages/pas/tests/clawback_tests.move @@ -2,7 +2,7 @@ module pas::clawback_tests; use pas::{ - chest, + account, clawback_funds, e2e::{test_tx, a_witness, A, b_witness, B, AWitness}, policy::PolicyCap @@ -14,13 +14,13 @@ use sui::balance::{Self, Balance}; fun clawback_managed_assets() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let mut clawback_request = chest.clawback_balance(50, scenario.ctx()); + let mut clawback_request = account.clawback_balance(50, scenario.ctx()); assert_eq!(clawback_request.data().funds().value(), 50); assert_eq!(clawback_request.data().owner(), @0x1); - assert_eq!(clawback_request.data().chest_id(), namespace.chest_address(@0x1).to_id()); + assert_eq!(clawback_request.data().account_id(), namespace.account_address(@0x1).to_id()); clawback_request.approve(a_witness()); @@ -31,7 +31,7 @@ fun clawback_managed_assets() { assert_eq!(balance.value(), 50); - chest.share(); + account.share(); balance.send_funds(@0x10); }); @@ -45,10 +45,10 @@ fun try_to_clawback_when_clawback_stamp_is_not_set() { let policy_cap = scenario.take_from_sender>>(); managed_policy.remove_action_approval(&policy_cap, "clawback_funds"); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let mut clawback_request = chest.clawback_balance(50, scenario.ctx()); + let mut clawback_request = account.clawback_balance(50, scenario.ctx()); clawback_request.approve(a_witness()); let balance = clawback_funds::resolve(clawback_request, managed_policy); @@ -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_policy, unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let mut clawback_request = chest.clawback_balance(50, scenario.ctx()); + let mut clawback_request = account.clawback_balance(50, scenario.ctx()); clawback_request.approve(b_witness()); let _balance = clawback_funds::resolve(clawback_request, unmanaged_policy); diff --git a/packages/pas/tests/e2e.move b/packages/pas/tests/e2e.move index 69512b6..a10278d 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::{chest::{Self, Chest}, policy::{Self, PolicyCap}, send_funds, unlock_funds}; +use pas::{account::{Self, Account}, policy::{Self, PolicyCap}, send_funds, unlock_funds}; use std::{type_name, unit_test::{assert_eq, destroy}}; use sui::{balance::{Self, send_funds, Balance}, sui::SUI, test_scenario::return_shared, vec_set}; @@ -19,33 +19,33 @@ fun e2e() { let namespace_id = object::id(namespace); - // create chests of 0x1 and 0x2 - let chest = chest::create(namespace, @0x1); - let another_chest = chest::create(namespace, @0x2); + // create accounts of 0x1 and 0x2 + let account = account::create(namespace, @0x1); + let another_account = account::create(namespace, @0x2); // transfer some funds to both 0x1 and 0x2 - chest.deposit_balance(balance::create_for_testing(100)); + account.deposit_balance(balance::create_for_testing(100)); - balance::create_for_testing(50).send_funds(namespace.chest_address(@0x2)); + balance::create_for_testing(50).send_funds(namespace.account_address(@0x2)); - chest.share(); - another_chest.share(); + account.share(); + another_account.share(); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let another_chest = scenario.take_shared_by_id(namespace - .chest_address(@0x2) + let another_account = scenario.take_shared_by_id(namespace + .account_address(@0x2) .to_id()); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.send_balance( &auth, - &another_chest, + &another_account, 50, scenario.ctx(), ); @@ -53,8 +53,8 @@ fun e2e() { transfer_request.approve(AWitness()); send_funds::resolve_balance(transfer_request, managed_policy); - return_shared(chest); - return_shared(another_chest); + return_shared(account); + return_shared(another_account); }); } @@ -63,18 +63,18 @@ fun try_to_approve_transfer_with_invalid_witness() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { let namespace_id = object::id(namespace); scenario.next_tx(@0x1); - chest::create_and_share(namespace, @0x1); + account::create_and_share(namespace, @0x1); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.unsafe_send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.unsafe_send_balance( &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_policy, _unmanaged_policy, scenario| { - let user_one_chest_id = namespace.chest_address(@0x1).to_id(); - let user_two_chest_id = namespace.chest_address(@0x2).to_id(); + let user_one_account_id = namespace.account_address(@0x1).to_id(); + let user_two_account_id = namespace.account_address(@0x2).to_id(); scenario.next_tx(@0x1); - chest::create_and_share(namespace, @0x1); - chest::create_and_share(namespace, @0x2); + account::create_and_share(namespace, @0x1); + account::create_and_share(namespace, @0x2); scenario.next_tx(@0x1); - 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 mut user_one_account = scenario.take_shared_by_id(user_one_account_id); + let user_two_account = scenario.take_shared_by_id(user_two_account_id); - let auth = chest::new_auth(scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); - let transfer_request = user_one_chest.unsafe_send_balance( + let transfer_request = user_one_account.unsafe_send_balance( &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_chest_id(), user_one_chest_id); - assert_eq!(transfer_request.data().recipient_chest_id(), user_two_chest_id); + assert_eq!(transfer_request.data().sender_account_id(), user_one_account_id); + assert_eq!(transfer_request.data().recipient_account_id(), user_two_account_id); assert_eq!(transfer_request.data().funds().value(), 50); // Both scenarios must calculate the from/to equivalent. - let safe_request = user_one_chest.send_balance( + let safe_request = user_one_account.send_balance( &auth, - &user_two_chest, + &user_two_account, 50, scenario.ctx(), ); assert_eq!(safe_request.data().sender(), @0x1); assert_eq!(safe_request.data().recipient(), @0x2); - 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().sender_account_id(), user_one_account_id); + assert_eq!(safe_request.data().recipient_account_id(), user_two_account_id); assert_eq!(safe_request.data().funds().value(), 50); destroy(transfer_request); destroy(safe_request); - return_shared(user_one_chest); - return_shared(user_two_chest); + return_shared(user_one_account); + return_shared(user_two_account); }); } @@ -144,18 +144,18 @@ fun test_address_and_derivation_matches() { fun unlock_funds_successfully() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let auth = chest::new_auth(scenario.ctx()); - let mut unlock_request = chest.unlock_balance(&auth, 50, scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); + let mut unlock_request = account.unlock_balance(&auth, 50, scenario.ctx()); unlock_request.approve(AWitness()); let balance = unlock_funds::resolve(unlock_request, managed_policy); assert_eq!(balance.value(), 50); - chest.share(); + account.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_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let auth = chest::new_auth(scenario.ctx()); - let unlock_request = chest.unlock_balance(&auth, 50, scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); + let unlock_request = account.unlock_balance(&auth, 50, scenario.ctx()); let _balance = unlock_funds::resolve_unrestricted_balance(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_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let auth = chest::new_auth(scenario.ctx()); - let unlock_request = chest.unlock_balance(&auth, 100, scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); + let unlock_request = account.unlock_balance(&auth, 100, scenario.ctx()); let balance = unlock_funds::resolve_unrestricted_balance(unlock_request, namespace); balance.send_funds(@0x1); - chest.share(); + account.share(); }); } @@ -197,12 +197,12 @@ fun unlock_non_managed_funds() { fun derivation_is_consistent() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let chest = chest::create(namespace, @0x1); + let account = account::create(namespace, @0x1); - assert_eq!(namespace.chest_address(@0x1), object::id(&chest).to_address()); + assert_eq!(namespace.account_address(@0x1), object::id(&account).to_address()); assert_eq!(namespace.policy_address>(), object::id(managed_policy).to_address()); - chest.share(); + account.share(); }); } @@ -210,19 +210,19 @@ fun derivation_is_consistent() { fun test_unlock_request_getters() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); - let mut chest = chest::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + let mut account = account::create(namespace, @0x1); + account.deposit_balance(balance::create_for_testing(100)); - let auth = chest::new_auth(scenario.ctx()); + let auth = account::new_auth(scenario.ctx()); - let unlock_request = chest.unlock_balance(&auth, 50, scenario.ctx()); + let unlock_request = account.unlock_balance(&auth, 50, scenario.ctx()); assert_eq!(unlock_request.data().owner(), @0x1); - assert_eq!(unlock_request.data().chest_id(), namespace.chest_address(@0x1).to_id()); + assert_eq!(unlock_request.data().account_id(), namespace.account_address(@0x1).to_id()); assert_eq!(unlock_request.data().funds().value(), 50); destroy(unlock_request); - chest.share(); + account.share(); }); } @@ -253,23 +253,23 @@ fun multiple_approvals_required() { scenario.return_to_sender(policy_cap); - // create chests of 0x1 and 0x2 - let chest = chest::create(namespace, @0x1); + // create accounts of 0x1 and 0x2 + let account = account::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - chest.deposit_balance(balance::create_for_testing(100)); - chest.share(); + account.deposit_balance(balance::create_for_testing(100)); + account.share(); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.unsafe_send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.unsafe_send_balance( &auth, @0x2, 50, @@ -280,7 +280,7 @@ fun multiple_approvals_required() { transfer_request.approve(BWitness()); send_funds::resolve_balance(transfer_request, managed_policy); - return_shared(chest); + return_shared(account); }); } @@ -300,23 +300,23 @@ fun multiple_approvals_invalid_order_failure() { scenario.return_to_sender(policy_cap); - // create chests of 0x1 and 0x2 - let chest = chest::create(namespace, @0x1); + // create accounts of 0x1 and 0x2 + let account = account::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - chest.deposit_balance(balance::create_for_testing(100)); - chest.share(); + account.deposit_balance(balance::create_for_testing(100)); + account.share(); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.unsafe_send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.unsafe_send_balance( &auth, @0x2, 50, @@ -337,23 +337,23 @@ fun cannot_have_extra_approvals() { let namespace_id = object::id(namespace); - // create chests of 0x1 and 0x2 - let chest = chest::create(namespace, @0x1); + // create accounts of 0x1 and 0x2 + let account = account::create(namespace, @0x1); // transfer some funds to both 0x1 and 0x2 - chest.deposit_balance(balance::create_for_testing(100)); - chest.share(); + account.deposit_balance(balance::create_for_testing(100)); + account.share(); scenario.next_tx(@0x1); - let mut chest = scenario.take_shared_by_id(namespace - .chest_address( + let mut account = scenario.take_shared_by_id(namespace + .account_address( @0x1, ) .to_id()); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.unsafe_send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.unsafe_send_balance( &auth, @0x2, 50, diff --git a/packages/pas/tests/policy_setup_tests.move b/packages/pas/tests/policy_setup_tests.move index b891cb6..d0a00d9 100644 --- a/packages/pas/tests/policy_setup_tests.move +++ b/packages/pas/tests/policy_setup_tests.move @@ -1,7 +1,7 @@ #[test_only, allow(unused_variable, unused_mut_ref, dead_code)] module pas::policy_setup_tests; -use pas::{chest, e2e::{test_tx, A}, policy::PolicyCap, send_funds}; +use pas::{account, e2e::{test_tx, A}, policy::PolicyCap, send_funds}; use sui::balance::{Self, 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 chest = chest::create(namespace, @0x1); + let mut account = account::create(namespace, @0x1); - chest.deposit_balance(balance::create_for_testing(100)); + account.deposit_balance(balance::create_for_testing(100)); - let auth = chest::new_auth(scenario.ctx()); - let mut transfer_request = chest.unsafe_send_balance( + let auth = account::new_auth(scenario.ctx()); + let mut transfer_request = account.unsafe_send_balance( &auth, @0x2, 50, @@ -32,7 +32,7 @@ fun override_action_approval() { transfer_request.approve(NewActionApproval()); send_funds::resolve_balance(transfer_request, managed_policy); - chest.share(); + account.share(); }; scenario.return_to_sender(policy_cap); diff --git a/packages/pas/tests/versioning_tests.move b/packages/pas/tests/versioning_tests.move index 24a5122..f614ddf 100644 --- a/packages/pas/tests/versioning_tests.move +++ b/packages/pas/tests/versioning_tests.move @@ -2,7 +2,7 @@ module pas::versioning_tests; use pas::{ - chest, + account, e2e::{package_id, test_tx, A}, namespace::{Self, Namespace}, versioning::breaking_version @@ -70,52 +70,52 @@ fun tries_to_unblock_version_with_invalid_upgrade_cap() { } #[test] -fun block_unblock_versions_and_sync_with_chests_and_policies() { +fun block_unblock_versions_and_sync_with_accounts_and_policies() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { scenario.next_tx(@0x1); let upgrade_cap = scenario.take_from_sender(); - let mut chest = chest::create(namespace, @0x1); + let mut account = account::create(namespace, @0x1); namespace.block_version(&upgrade_cap, 1); assert!(!namespace.versioning().is_valid_version(1)); - chest.sync_versioning(namespace); + account.sync_versioning(namespace); managed_policy.sync_versioning(namespace); - assert_eq!(chest.versioning(), namespace.versioning()); - assert!(!chest.versioning().is_valid_version(1)); + assert_eq!(account.versioning(), namespace.versioning()); + assert!(!account.versioning().is_valid_version(1)); assert!(!managed_policy.versioning().is_valid_version(1)); namespace.unblock_version(&upgrade_cap, 1); - chest.sync_versioning(namespace); + account.sync_versioning(namespace); managed_policy.sync_versioning(namespace); assert!(namespace.versioning().is_valid_version(1)); - assert!(chest.versioning().is_valid_version(1)); + assert!(account.versioning().is_valid_version(1)); assert!(managed_policy.versioning().is_valid_version(1)); - chest.share(); + account.share(); scenario.return_to_sender(upgrade_cap); }); } #[test, expected_failure(abort_code = ::pas::versioning::EInvalidVersion)] -fun try_to_create_chest_with_invalid_version() { +fun try_to_create_account_with_invalid_version() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { namespace.block_current_version(scenario); - let _chest = chest::create(namespace, @0x1); + let _account = account::create(namespace, @0x1); abort }); } #[test, expected_failure(abort_code = ::pas::versioning::EInvalidVersion)] -fun try_unlock_funds_invalid_version_on_chest() { +fun try_unlock_funds_invalid_version_on_account() { test_tx!(@0x1, |namespace, managed_policy, _unmanaged_policy, scenario| { - let mut chest = chest::create(namespace, @0x1); + let mut account = account::create(namespace, @0x1); namespace.block_current_version(scenario); - chest.sync_versioning(namespace); - let auth = chest::new_auth(scenario.ctx()); - let req = chest.unlock_balance(&auth, 50, scenario.ctx()); + account.sync_versioning(namespace); + let auth = account::new_auth(scenario.ctx()); + let req = account.unlock_balance(&auth, 50, scenario.ctx()); abort }); } diff --git a/sdk/example-app/src/extension-example.ts b/sdk/example-app/src/extension-example.ts index 13f79d7..3564d2f 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 createChestForAddress(client, sender); - // await createChestForAddress(client, '0x2'); + // await createAccountForAddress(client, sender); + // await createAccountForAddress(client, '0x2'); - // console.log(client.pas.deriveChestAddress(sender)); - // await mintFromDemoFaucetAndTransferToChest(client, 10, sender); + // console.log(client.pas.deriveAccountAddress(sender)); + // await mintFromDemoFaucetAndTransferToAccount(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 chest's balance.) +// Queries the balances for address (both the addr balance, and the account's balance.) async function getBalancesForAddress(client: PasClientType, address: string) { const addr = normalizeSuiAddress(address); - const [addressBalance, chestBalance] = await Promise.all([ + const [addressBalance, accountBalance] = await Promise.all([ client.core.getBalance({ owner: addr, coinType: assetType }), client.core.getBalance({ - owner: client.pas.deriveChestAddress(address), + owner: client.pas.deriveAccountAddress(address), coinType: assetType }) ]); - return { addressBalance, chestBalance }; + return { addressBalance, accountBalance }; } -async function mintFromDemoFaucetAndTransferToChest(client: PasClientType, amount: number, owner: string) { +async function mintFromDemoFaucetAndTransferToAccount(client: PasClientType, amount: number, owner: string) { const tx = new Transaction(); const balance = tx.moveCall({ @@ -76,7 +76,7 @@ async function mintFromDemoFaucetAndTransferToChest(client: PasClientType, amoun tx.moveCall({ target: `0x2::balance::send_funds`, - arguments: [balance, tx.pure.address(client.pas.deriveChestAddress(owner))], + arguments: [balance, tx.pure.address(client.pas.deriveAccountAddress(owner))], typeArguments: [assetType] }) @@ -94,9 +94,9 @@ async function finalizeTestAssetSetup(client: PasClientType) { await signAndExecute(client, tx); } -async function createChestForAddress(client: PasClientType, address: string) { +async function createAccountForAddress(client: PasClientType, address: string) { const tx = new Transaction(); - tx.add(client.pas.tx.chestForAddress(address)); + tx.add(client.pas.tx.accountForAddress(address)); return signAndExecute(client, tx); } diff --git a/sdk/pas/src/client.ts b/sdk/pas/src/client.ts index efd2422..672a467 100644 --- a/sdk/pas/src/client.ts +++ b/sdk/pas/src/client.ts @@ -9,14 +9,14 @@ import { TESTNET_PAS_PACKAGE_CONFIG, } from './constants.js'; import { - deriveChestAddress, + deriveAccountAddress, derivePolicyAddress, deriveTemplateAddress, deriveTemplateRegistryAddress, } from './derivation.js'; import { PASClientError } from './error.js'; import { - chestForAddressIntent, + accountForAddressIntent, sendBalanceIntent, unlockBalanceIntent, unlockUnrestrictedBalanceIntent, @@ -104,13 +104,13 @@ export class PASClient { } /** - * Derives the chest address for a given owner address. + * Derives the account address for a given owner address. * * @param owner - The owner address (can be a user address or object address) - * @returns The derived chest object ID + * @returns The derived account object ID */ - deriveChestAddress(owner: string): string { - return deriveChestAddress(owner, this.#packageConfig); + deriveAccountAddress(owner: string): string { + return deriveAccountAddress(owner, this.#packageConfig); } /** @@ -153,11 +153,11 @@ export class PASClient { /** * Creates a transfer funds intent. At build time, it auto-resolves the issuer's * approval template commands by reading the Policy and Templates objects on-chain. - * If the recipient chest does not exist, it will be created and shared automatically. + * If the recipient account 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 chest) - * @param options.to - The receiver's address (owner of the destination chest) + * @param options.from - The sender's address (owner of the source account) + * @param options.to - The receiver's address (owner of the destination account) * @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` @@ -170,7 +170,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 chest) + * @param options.from - The sender's address (owner of the source account) * @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` @@ -182,7 +182,7 @@ export class PASClient { * Use this when no Policy exists for the asset type (e.g., SUI). * * @param options - Unlock options - * @param options.from - The sender's address (owner of the source chest) + * @param options.from - The sender's address (owner of the source account) * @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` @@ -190,14 +190,14 @@ export class PASClient { unlockUnrestrictedBalance: unlockUnrestrictedBalanceIntent(this.#packageConfig), /** - * Returns a chest object for the given address. At build time, if the chest + * Returns a account object for the given address. At build time, if the account * already exists on-chain it resolves to an object reference; otherwise it - * creates the chest and shares it. + * creates the account and shares it. * * @param owner - The owner address - * @returns A sync closure `(tx: Transaction) => TransactionResult` (the chest) + * @returns A sync closure `(tx: Transaction) => TransactionResult` (the account) */ - chestForAddress: chestForAddressIntent(this.#packageConfig), + accountForAddress: accountForAddressIntent(this.#packageConfig), }; } } diff --git a/sdk/pas/src/contracts/pas/chest.ts b/sdk/pas/src/contracts/pas/account.ts similarity index 85% rename from sdk/pas/src/contracts/pas/chest.ts rename to sdk/pas/src/contracts/pas/account.ts index b8999af..edb152e 100644 --- a/sdk/pas/src/contracts/pas/chest.ts +++ b/sdk/pas/src/contracts/pas/account.ts @@ -2,7 +2,7 @@ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * **************************************************************/ -/** Chest logic */ +/** Account 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::chest'; -export const Chest = new MoveStruct({ - name: `${$moduleName}::Chest`, +const $moduleName = '@mysten/pas::account'; +export const Account = new MoveStruct({ + name: `${$moduleName}::Account`, fields: { id: bcs.Address, - /** The owner of the chest (address or object) */ + /** The owner of the account (address or object) */ owner: bcs.Address, /** - * The ID of the namespace that created this chest. There's ONLY ONE namespace in + * The ID of the namespace that created this account. 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 chest for `owner`. This is a permission-less action. */ +/** Create a new account 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: 'chest', + module: 'account', function: 'create', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface ShareArguments { - chest: RawTransactionArgument; + account: RawTransactionArgument; } export interface ShareOptions { package?: string; - arguments: ShareArguments | [chest: RawTransactionArgument]; + arguments: ShareArguments | [account: RawTransactionArgument]; } /** - * The only way to finalize the TX is by sharing the chest. All chests are shared + * The only way to finalize the TX is by sharing the account. All accounts are shared * by default. */ export function share(options: ShareOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['chest']; + const parameterNames = ['account']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'share', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); @@ -92,7 +92,7 @@ export interface CreateAndShareOptions { | CreateAndShareArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -/** Create and share a chest in a single step. */ +/** Create and share a account 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: 'chest', + module: 'account', function: 'create_and_share', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface UnlockBalanceArguments { - chest: RawTransactionArgument; + account: RawTransactionArgument; auth: RawTransactionArgument; amount: RawTransactionArgument; } @@ -115,7 +115,7 @@ export interface UnlockBalanceOptions { arguments: | UnlockBalanceArguments | [ - chest: RawTransactionArgument, + account: RawTransactionArgument, auth: RawTransactionArgument, amount: RawTransactionArgument, ]; @@ -129,11 +129,11 @@ export interface UnlockBalanceOptions { export function unlockBalance(options: UnlockBalanceOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; - const parameterNames = ['chest', 'auth', 'amount']; + const parameterNames = ['account', 'auth', 'amount']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'unlock_balance', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -157,7 +157,7 @@ export interface SendBalanceOptions { ]; typeArguments: [string]; } -/** Initiate a transfer from chest A to chest B. */ +/** Initiate a transfer from account A to account B. */ export function sendBalance(options: SendBalanceOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; @@ -165,7 +165,7 @@ export function sendBalance(options: SendBalanceOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'send_balance', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -195,7 +195,7 @@ export function clawbackBalance(options: ClawbackBalanceOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'clawback_balance', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, @@ -220,7 +220,7 @@ export interface UnsafeSendBalanceOptions { typeArguments: [string]; } /** - * Transfer `amount` from chest to an address. This unlocks transfers to a chest + * Transfer `amount` from account to an address. This unlocks transfers to a account * 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 unsafeSendBalance(options: UnsafeSendBalanceOptions) { return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'unsafe_send_balance', 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: 'chest', + module: 'account', 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 chests. */ +/** Generate an ownership proof from a `UID` object, to allow objects to own accounts. */ 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: 'chest', + module: 'account', function: 'new_auth_as_object', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface OwnerArguments { - chest: RawTransactionArgument; + account: RawTransactionArgument; } export interface OwnerOptions { package?: string; - arguments: OwnerArguments | [chest: RawTransactionArgument]; + arguments: OwnerArguments | [account: RawTransactionArgument]; } export function owner(options: OwnerOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; - const parameterNames = ['chest']; + const parameterNames = ['account']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'owner', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } export interface DepositBalanceArguments { - chest: RawTransactionArgument; + account: RawTransactionArgument; balance: RawTransactionArgument; } export interface DepositBalanceOptions { package?: string; arguments: | DepositBalanceArguments - | [chest: RawTransactionArgument, balance: RawTransactionArgument]; + | [account: RawTransactionArgument, balance: RawTransactionArgument]; typeArguments: [string]; } export function depositBalance(options: DepositBalanceOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, null] satisfies (string | null)[]; - const parameterNames = ['chest', 'balance']; + const parameterNames = ['account', 'balance']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', function: 'deposit_balance', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SyncVersioningArguments { - chest: RawTransactionArgument; + account: RawTransactionArgument; namespace: RawTransactionArgument; } export interface SyncVersioningOptions { package?: string; arguments: | SyncVersioningArguments - | [chest: RawTransactionArgument, namespace: RawTransactionArgument]; + | [account: 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 = ['chest', 'namespace']; + const parameterNames = ['account', 'namespace']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, - module: 'chest', + module: 'account', 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 2e92a10..92bd4ca 100644 --- a/sdk/pas/src/contracts/pas/clawback_funds.ts +++ b/sdk/pas/src/contracts/pas/clawback_funds.ts @@ -11,10 +11,10 @@ export function ClawbackFunds>(...typeParameters: [T]) { return new MoveStruct({ name: `${$moduleName}::ClawbackFunds<${typeParameters[0].name as T['name']}>`, fields: { - /** `owner` is the wallet OR object address, NOT the chest address */ + /** `owner` is the wallet OR object address, NOT the account address */ owner: bcs.Address, - /** The ID of the chest the funds are coming from */ - chest_id: bcs.Address, + /** The ID of the account the funds are coming from */ + account_id: bcs.Address, /** The balance that is being clawed back. */ funds: typeParameters[0], }, @@ -41,15 +41,15 @@ export function owner(options: OwnerOptions) { typeArguments: options.typeArguments, }); } -export interface ChestIdArguments { +export interface AccountIdArguments { request: RawTransactionArgument; } -export interface ChestIdOptions { +export interface AccountIdOptions { package?: string; - arguments: ChestIdArguments | [request: RawTransactionArgument]; + arguments: AccountIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function chestId(options: ChestIdOptions) { +export function accountId(options: AccountIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -57,7 +57,7 @@ export function chestId(options: ChestIdOptions) { tx.moveCall({ package: packageAddress, module: 'clawback_funds', - function: 'chest_id', + function: 'account_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 a8721b2..376362f 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 PolicyKey = new MoveTuple({ name: `${$moduleName}::PolicyKey`, fields: [bcs.bool()] }); -export const ChestKey = new MoveTuple({ name: `${$moduleName}::ChestKey`, fields: [bcs.Address] }); +export const AccountKey = new MoveTuple({ name: `${$moduleName}::AccountKey`, 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 c0fb2ac..a913089 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. Chests + * 1. Accounts * 2. Policies ... any other module we might add in the future */ @@ -163,17 +163,17 @@ export function policyAddress(options: PolicyAddressOptions) { typeArguments: options.typeArguments, }); } -export interface ChestExistsArguments { +export interface AccountExistsArguments { namespace: RawTransactionArgument; owner: RawTransactionArgument; } -export interface ChestExistsOptions { +export interface AccountExistsOptions { package?: string; arguments: - | ChestExistsArguments + | AccountExistsArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -export function chestExists(options: ChestExistsOptions) { +export function accountExists(options: AccountExistsOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; const parameterNames = ['namespace', 'owner']; @@ -181,21 +181,21 @@ export function chestExists(options: ChestExistsOptions) { tx.moveCall({ package: packageAddress, module: 'namespace', - function: 'chest_exists', + function: 'account_exists', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } -export interface ChestAddressArguments { +export interface AccountAddressArguments { namespace: RawTransactionArgument; owner: RawTransactionArgument; } -export interface ChestAddressOptions { +export interface AccountAddressOptions { package?: string; arguments: - | ChestAddressArguments + | AccountAddressArguments | [namespace: RawTransactionArgument, owner: RawTransactionArgument]; } -export function chestAddress(options: ChestAddressOptions) { +export function accountAddress(options: AccountAddressOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null, 'address'] satisfies (string | null)[]; const parameterNames = ['namespace', 'owner']; @@ -203,7 +203,7 @@ export function chestAddress(options: ChestAddressOptions) { tx.moveCall({ package: packageAddress, module: 'namespace', - function: 'chest_address', + function: 'account_address', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), }); } diff --git a/sdk/pas/src/contracts/pas/send_funds.ts b/sdk/pas/src/contracts/pas/send_funds.ts index cac647e..97eee3a 100644 --- a/sdk/pas/src/contracts/pas/send_funds.ts +++ b/sdk/pas/src/contracts/pas/send_funds.ts @@ -28,14 +28,14 @@ export function SendFunds>(...typeParameters: [T]) { return new MoveStruct({ name: `${$moduleName}::SendFunds<${typeParameters[0].name as T['name']}>`, fields: { - /** `sender` is the wallet OR object address, NOT the chest address */ + /** `sender` is the wallet OR object address, NOT the account address */ sender: bcs.Address, - /** `recipient` is the wallet OR object address, NOT the chest address */ + /** `recipient` is the wallet OR object address, NOT the account address */ recipient: 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 ID of the account the funds are coming from */ + sender_account_id: bcs.Address, + /** The ID of the account the funds are going to */ + recipient_account_id: bcs.Address, /** The balance being transferred */ funds: typeParameters[0], }, @@ -83,15 +83,15 @@ export function recipient(options: RecipientOptions) { typeArguments: options.typeArguments, }); } -export interface SenderChestIdArguments { +export interface SenderAccountIdArguments { request: RawTransactionArgument; } -export interface SenderChestIdOptions { +export interface SenderAccountIdOptions { package?: string; - arguments: SenderChestIdArguments | [request: RawTransactionArgument]; + arguments: SenderAccountIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function senderChestId(options: SenderChestIdOptions) { +export function senderAccountId(options: SenderAccountIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -99,20 +99,20 @@ export function senderChestId(options: SenderChestIdOptions) { tx.moveCall({ package: packageAddress, module: 'send_funds', - function: 'sender_chest_id', + function: 'sender_account_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } -export interface RecipientChestIdArguments { +export interface RecipientAccountIdArguments { request: RawTransactionArgument; } -export interface RecipientChestIdOptions { +export interface RecipientAccountIdOptions { package?: string; - arguments: RecipientChestIdArguments | [request: RawTransactionArgument]; + arguments: RecipientAccountIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function recipientChestId(options: RecipientChestIdOptions) { +export function recipientAccountId(options: RecipientAccountIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -120,7 +120,7 @@ export function recipientChestId(options: RecipientChestIdOptions) { tx.moveCall({ package: packageAddress, module: 'send_funds', - function: 'recipient_chest_id', + function: 'recipient_account_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 2ca7963..fcfdb8d 100644 --- a/sdk/pas/src/contracts/pas/unlock_funds.ts +++ b/sdk/pas/src/contracts/pas/unlock_funds.ts @@ -23,10 +23,10 @@ export function UnlockFunds>(...typeParameters: [T]) { return new MoveStruct({ name: `${$moduleName}::UnlockFunds<${typeParameters[0].name as T['name']}>`, fields: { - /** `from` is the wallet OR object address, NOT the chest address */ + /** `from` is the wallet OR object address, NOT the account address */ owner: bcs.Address, - /** The ID of the chest the funds are coming from */ - chest_id: bcs.Address, + /** The ID of the account the funds are coming from */ + account_id: bcs.Address, /** The actual balance being transferred */ funds: typeParameters[0], }, @@ -53,15 +53,15 @@ export function owner(options: OwnerOptions) { typeArguments: options.typeArguments, }); } -export interface ChestIdArguments { +export interface AccountIdArguments { request: RawTransactionArgument; } -export interface ChestIdOptions { +export interface AccountIdOptions { package?: string; - arguments: ChestIdArguments | [request: RawTransactionArgument]; + arguments: AccountIdArguments | [request: RawTransactionArgument]; typeArguments: [string]; } -export function chestId(options: ChestIdOptions) { +export function accountId(options: AccountIdOptions) { const packageAddress = options.package ?? '@mysten/pas'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['request']; @@ -69,7 +69,7 @@ export function chestId(options: ChestIdOptions) { tx.moveCall({ package: packageAddress, module: 'unlock_funds', - function: 'chest_id', + function: 'account_id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); @@ -112,7 +112,7 @@ export interface ResolveUnrestrictedBalanceOptions { * 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 chest. + * to withdraw if anyone transfers some to their account. */ export function resolveUnrestrictedBalance(options: ResolveUnrestrictedBalanceOptions) { const packageAddress = options.package ?? '@mysten/pas'; diff --git a/sdk/pas/src/derivation.ts b/sdk/pas/src/derivation.ts index 9370789..5cdf5f6 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 chest address for a given owner address. + * Derives the account address for a given owner address. * - * Chests are derived using the namespace UID and a ChestKey(owner). - * The key structure in Move is: `ChestKey(address)` + * Accounts are derived using the namespace UID and a AccountKey(owner). + * The key structure in Move is: `AccountKey(address)` * * @param owner - The owner address (can be a user address or object address) * @param packageConfig - PAS package configuration - * @returns The derived chest object ID + * @returns The derived account object ID */ -export function deriveChestAddress(owner: string, packageConfig: PASPackageConfig): string { +export function deriveAccountAddress(owner: string, packageConfig: PASPackageConfig): string { const { packageId, namespaceId } = packageConfig; - // Serialize the ChestKey(address) as the key - // ChestKey is a struct with a single field: address - const chestKeyBcs = bcs.struct('ChestKey', { + // Serialize the AccountKey(address) as the key + // AccountKey is a struct with a single field: address + const accountKeyBcs = bcs.struct('AccountKey', { owner: bcs.Address, }); - const key = chestKeyBcs.serialize({ owner: normalizeSuiAddress(owner) }).toBytes(); + const key = accountKeyBcs.serialize({ owner: normalizeSuiAddress(owner) }).toBytes(); - // The type tag is the ChestKey type from the PAS package - const typeTag = `${packageId}::keys::ChestKey`; + // The type tag is the AccountKey type from the PAS package + const typeTag = `${packageId}::keys::AccountKey`; return deriveObjectID(namespaceId, typeTag, key); } diff --git a/sdk/pas/src/intents.ts b/sdk/pas/src/intents.ts index 908f247..a5eeb34 100644 --- a/sdk/pas/src/intents.ts +++ b/sdk/pas/src/intents.ts @@ -15,7 +15,7 @@ import type { import { normalizeStructTag } from '@mysten/sui/utils'; import { - deriveChestAddress, + deriveAccountAddress, derivePolicyAddress, deriveTemplateAddress, deriveTemplateRegistryAddress, @@ -60,8 +60,8 @@ type UnlockUnrestrictedBalanceIntentData = { cfg: PASPackageConfig; }; -type ChestForAddressIntentData = { - action: 'chestForAddress'; +type AccountForAddressIntentData = { + action: 'accountForAddress'; owner: string; cfg: PASPackageConfig; }; @@ -70,7 +70,7 @@ type PASIntentData = | SendBalanceIntentData | UnlockBalanceIntentData | UnlockUnrestrictedBalanceIntentData - | ChestForAddressIntentData; + | AccountForAddressIntentData; /** * Creates a memoized PAS intent closure. On first call it registers the @@ -146,11 +146,11 @@ export function unlockUnrestrictedBalanceIntent( }); } -export function chestForAddressIntent( +export function accountForAddressIntent( packageConfig: PASPackageConfig, ): (owner: string) => (tx: Transaction) => TransactionResult { return (owner: string) => - createPASIntent({ action: 'chestForAddress', owner, cfg: packageConfig }); + createPASIntent({ action: 'accountForAddress', owner, cfg: packageConfig }); } // --------------------------------------------------------------------------- @@ -171,7 +171,7 @@ export function chestForAddressIntent( // // baseIdx = the position of the $Intent slot being replaced // -// So if baseIdx is 3 and we push 2 chest-creation commands before the +// So if baseIdx is 3 and we push 2 account-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 chestForAddressIntent( type SuiObject = SuiClientTypes.Object<{ content: true }>; -type ChestState = { kind: 'existing' } | { kind: 'created'; resultIndex: number }; +type AccountState = { 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 (chests, rules). null = does not exist. */ + /** Pre-fetched on-chain objects (accounts, rules). null = does not exist. */ readonly objects: Map; /** Pre-fetched template dynamic field objects. */ readonly templates: Map; /** Pre-parsed template lookup: policyId:actionType -> approval type names. */ readonly templateApprovals: Map; - /** Chest existence / creation tracking. */ - readonly chests: Map; + /** Account existence / creation tracking. */ + readonly accounts: Map; readonly #tx: TransactionDataBuilder; readonly #inputCache = new Map(); @@ -216,21 +216,21 @@ class Resolver { objects, templates, templateApprovals, - chests, + accounts, config, }: { transactionData: TransactionDataBuilder; objects: Map; templates: Map; templateApprovals: Map; - chests: Map; + accounts: Map; config: PASPackageConfig; }) { this.#tx = transactionData; this.objects = objects; this.templates = templates; this.templateApprovals = templateApprovals; - this.chests = chests; + this.accounts = accounts; this.#config = config; } @@ -272,26 +272,26 @@ class Resolver { return obj; } - // -- Chest resolution ---------------------------------------------------- + // -- Account resolution ---------------------------------------------------- /** - * Returns an Argument referencing the chest for `chestId`. + * Returns an Argument referencing the account for `accountId`. * - * - Existing on-chain chest: returns an object Input. + * - Existing on-chain account: returns an object Input. * - Already created earlier in this PTB: returns the stored Result ref. - * - Does not exist yet: **pushes** a `chest::create` MoveCall into the + * - Does not exist yet: **pushes** a `account::create` MoveCall into the * caller's `commands` array (mutating it) and records the creation so - * subsequent calls for the same chest reuse the same Result. The chest - * will be shared at the end of the PTB via `shareNewChests()`. + * subsequent calls for the same account reuse the same Result. The account + * will be shared at the end of the PTB via `shareNewAccounts()`. * * @param commands - The caller's local command array (may be mutated). * @param baseIdx - Absolute PTB index where `commands[0]` will land. */ - resolveChestArg(chestId: string, owner: string, baseIdx: number): [Argument, Command[]] { - const state = this.chests.get(chestId); + resolveAccountArg(accountId: string, owner: string, baseIdx: number): [Argument, Command[]] { + const state = this.accounts.get(accountId); const commands: Command[] = []; - if (state?.kind === 'existing') return [this.addObjectInput(chestId), commands]; + if (state?.kind === 'existing') return [this.addObjectInput(accountId), 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: 'chest', + module: 'account', function: 'create', arguments: [ this.addObjectInput(this.#config.namespaceId), @@ -309,7 +309,7 @@ class Resolver { }), ); - this.chests.set(chestId, { kind: 'created', resultIndex: absoluteIndex }); + this.accounts.set(accountId, { kind: 'created', resultIndex: absoluteIndex }); return [{ $kind: 'Result', Result: absoluteIndex }, commands]; } @@ -353,23 +353,23 @@ class Resolver { } /** - * Replaces a chestForAddress intent when the chest already exists. + * Replaces a accountForAddress intent when the account already exists. * The intent is removed (0 replacement commands) and external references - * are remapped to the existing chest's Input argument. + * are remapped to the existing account's Input argument. * * Note: SDK's replaceCommand signature doesn't accept Input args as * resultIndex, but the runtime handles it correctly via ArgumentSchema.parse(). */ - replaceIntentWithExistingChest(actualIdx: number, chestArg: Argument) { - this.#tx.replaceCommand(actualIdx, [], chestArg as any); + replaceIntentWithExistingAccount(actualIdx: number, accountArg: Argument) { + this.#tx.replaceCommand(actualIdx, [], accountArg as any); } /** - * 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). + * Replaces a accountForAddress intent when the account needs to be created. + * The intent is replaced with the account::create command(s), and external + * references are remapped to the first command's Result (the new account). */ - replaceIntentWithCreatedChest(actualIdx: number, commands: Command[]) { + replaceIntentWithCreatedAccount(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: - // [chest::create (0..N)] -- only if chests don't exist yet - // chest::new_auth -- create ownership proof - // chest::send_funds -- initiate the request + // [account::create (0..N)] -- only if accounts don't exist yet + // account::new_auth -- create ownership proof + // account::send_funds -- initiate the request // [approval commands] -- issuer-defined template commands // send_funds::resolve -- finalize and produce the output // @@ -391,8 +391,8 @@ class Resolver { buildSendBalance(data: SendBalanceIntentData, baseIdx: number): BuildResult { const { from, to, assetType, amount } = data; - const fromChestId = deriveChestAddress(from, this.#config); - const toChestId = deriveChestAddress(to, this.#config); + const fromAccountId = deriveAccountAddress(from, this.#config); + const toAccountId = deriveAccountAddress(to, this.#config); const policyId = derivePolicyAddress(assetType, this.#config); const policyObject = this.getObjectOrThrow(policyId, () => new PolicyNotFoundError(assetType)); @@ -401,37 +401,37 @@ class Resolver { PASActionType.SendFunds, ); - const [toChestArg, commands] = this.resolveChestArg(toChestId, to, baseIdx); - const [fromChestArg, fromChestCommands] = this.resolveChestArg( - fromChestId, + const [toAccountArg, commands] = this.resolveAccountArg(toAccountId, to, baseIdx); + const [fromAccountArg, fromAccountCommands] = this.resolveAccountArg( + fromAccountId, from, baseIdx + commands.length, ); - commands.push(...fromChestCommands); + commands.push(...fromAccountCommands); const policyArg = this.addObjectInput(policyId); - // chest::new_auth + // account::new_auth const authIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'chest', + module: 'account', function: 'new_auth', }), ); - // chest::send_funds + // account::send_funds const requestIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'chest', + module: 'account', function: 'send_balance', arguments: [ - fromChestArg, + fromAccountArg, { $kind: 'Result', Result: authIdx }, - toChestArg, + toAccountArg, 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), - senderChest: fromChestArg, - receiverChest: toChestArg, + senderAccount: fromAccountArg, + receiverAccount: toAccountArg, policy: policyArg, request: requestArg, systemType: assetType, @@ -478,7 +478,7 @@ class Resolver { baseIdx: number, ): BuildResult { const { from, assetType, amount } = data; - const fromChestId = deriveChestAddress(from, this.#config); + const fromAccountId = deriveAccountAddress(from, this.#config); const policyId = derivePolicyAddress(assetType, this.#config); const isRestricted = data.action === 'unlockBalance'; @@ -501,28 +501,28 @@ class Resolver { } } - const [fromChestArg, commands] = this.resolveChestArg(fromChestId, from, baseIdx); + const [fromAccountArg, commands] = this.resolveAccountArg(fromAccountId, from, baseIdx); const policyArg = isRestricted ? this.addObjectInput(policyId) : undefined; - // chest::new_auth + // account::new_auth const authIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'chest', + module: 'account', function: 'new_auth', }), ); - // chest::unlock_funds + // account::unlock_funds const requestIdx = baseIdx + commands.length; commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'chest', + module: 'account', function: 'unlock_balance', arguments: [ - fromChestArg, + fromAccountArg, { $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), - senderChest: fromChestArg, + senderAccount: fromAccountArg, policy: policyArg, request: requestArg, systemType: assetType, @@ -577,18 +577,18 @@ class Resolver { // -- Finalization --------------------------------------------------------- /** - * Appends `chest::share` commands for every chest that was created during + * Appends `account::share` commands for every account that was created during * resolution. Called once at the end, after all intents have been resolved, - * so that each chest is shared exactly once regardless of how many intents + * so that each account is shared exactly once regardless of how many intents * referenced it. */ - shareNewChests() { - for (const state of this.chests.values()) { + shareNewAccounts() { + for (const state of this.accounts.values()) { if (state.kind !== 'created') continue; this.#tx.commands.push( TransactionCommands.MoveCall({ package: this.#config.packageId, - module: 'chest', + module: 'account', function: 'share', arguments: [{ $kind: 'Result', Result: state.resultIndex }], }), @@ -601,11 +601,11 @@ class Resolver { // Data collection + fetching (pre-resolution) // --------------------------------------------------------------------------- -type ChestOwner = { owner: string }; +type AccountOwner = { owner: string }; interface IntentDataCollection { objectIds: Set; - chestRequests: Map; + accountRequests: 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 chestRequests = new Map(); + const accountRequests = new Map(); const intentDataList: PASIntentData[] = []; let cfg: PASPackageConfig | null = null; @@ -626,27 +626,27 @@ function collectIntentData(commands: readonly Command[]): IntentDataCollection | switch (data.action) { case 'sendBalance': { - const fromId = deriveChestAddress(data.from, cfg); - const toId = deriveChestAddress(data.to, cfg); + const fromId = deriveAccountAddress(data.from, cfg); + const toId = deriveAccountAddress(data.to, cfg); objectIds.add(fromId); objectIds.add(toId); objectIds.add(derivePolicyAddress(data.assetType, cfg)); - chestRequests.set(fromId, { owner: data.from }); - chestRequests.set(toId, { owner: data.to }); + accountRequests.set(fromId, { owner: data.from }); + accountRequests.set(toId, { owner: data.to }); break; } case 'unlockBalance': case 'unlockUnrestrictedBalance': { - const fromId = deriveChestAddress(data.from, cfg); + const fromId = deriveAccountAddress(data.from, cfg); objectIds.add(fromId); objectIds.add(derivePolicyAddress(data.assetType, cfg)); - chestRequests.set(fromId, { owner: data.from }); + accountRequests.set(fromId, { owner: data.from }); break; } - case 'chestForAddress': { - const id = deriveChestAddress(data.owner, cfg); + case 'accountForAddress': { + const id = deriveAccountAddress(data.owner, cfg); objectIds.add(id); - chestRequests.set(id, { owner: data.owner }); + accountRequests.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, chestRequests, intentDataList, cfg } : null; + return intentDataList.length > 0 ? { objectIds, accountRequests, intentDataList, cfg } : null; } async function initializeContext( transactionData: TransactionDataBuilder, client: ClientWithCoreApi, objectIds: Set, - chestRequests: Map, + accountRequests: Map, intentDataList: PASIntentData[], config: PASPackageConfig, ): Promise { - // 1. Batch-fetch all chests + rules + // 1. Batch-fetch all accounts + 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 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' }); + // 2. Build initial account map (existing vs needs-creation) + const accounts = new Map(); + for (const [accountId] of accountRequests) { + if (objects.get(accountId) !== null) { + accounts.set(accountId, { kind: 'existing' }); } } @@ -741,7 +741,7 @@ async function initializeContext( objects, templates, templateApprovals, - chests, + accounts, config, }); } @@ -756,13 +756,13 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption const requirements = collectIntentData(transactionData.commands); if (!requirements) return next(); - const { objectIds, chestRequests, intentDataList, cfg } = requirements; + const { objectIds, accountRequests, intentDataList, cfg } = requirements; const ctx = await initializeContext( transactionData, client, objectIds, - chestRequests, + accountRequests, intentDataList, cfg, ); @@ -775,15 +775,15 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption const data = command.$Intent.data as unknown as PASIntentData; - // -- 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); + // -- accountForAddress is handled separately (may produce 0 commands) -- + if (data.action === 'accountForAddress') { + const accountId = deriveAccountAddress(data.owner, cfg); + const [accountArg, commands] = ctx.resolveAccountArg(accountId, data.owner, index); if (commands.length === 0) { - ctx.replaceIntentWithExistingChest(index, chestArg); + ctx.replaceIntentWithExistingAccount(index, accountArg); } else { - ctx.replaceIntentWithCreatedChest(index, commands); + ctx.replaceIntentWithCreatedAccount(index, commands); } continue; } @@ -805,6 +805,6 @@ const resolvePASIntents: TransactionPlugin = async (transactionData, buildOption ctx.replaceIntent(index, result.commands, result.resultOffset); } - ctx.shareNewChests(); + ctx.shareNewAccounts(); return next(); }; diff --git a/sdk/pas/src/resolution.ts b/sdk/pas/src/resolution.ts index 52ce10f..88bba7a 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 Policies. */ export enum PASActionType { - /** Transfer funds between chests */ + /** Transfer funds between accounts */ SendFunds = 'send_funds', - /** Unlock funds from a chest */ + /** Unlock funds from a account */ UnlockFunds = 'unlock_funds', - /** Clawback funds from a chest */ + /** Clawback funds from a account */ 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 chest argument (already resolved) */ - senderChest?: Argument; - /** The receiver chest argument (already resolved) */ - receiverChest?: Argument; + /** The sender account argument (already resolved) */ + senderAccount?: Argument; + /** The receiver account argument (already resolved) */ + receiverAccount?: Argument; /** The policy argument (already resolved) */ policy?: Argument; /** The request argument (already resolved) */ @@ -232,13 +232,13 @@ function resolveRawPasRequest(args: RawCommandBuildArgs, extInput: { _namespace: case 'policy': if (!args.policy) throw new PASClientError(`Policy is not set in the context.`); return args.policy; - case 'sender_chest': - if (!args.senderChest) throw new PASClientError(`Sender chest is not set in the context.`); - return args.senderChest; - case 'receiver_chest': - if (!args.receiverChest) - throw new PASClientError(`Receiver chest is not set in the context.`); - return args.receiverChest; + case 'sender_account': + if (!args.senderAccount) throw new PASClientError(`Sender account is not set in the context.`); + return args.senderAccount; + case 'receiver_account': + if (!args.receiverAccount) + throw new PASClientError(`Receiver account is not set in the context.`); + return args.receiverAccount; default: throw new PASClientError(`Unknown pas request: ${extInput.value}`); } diff --git a/sdk/pas/test/e2e/e2e.isolated.test.ts b/sdk/pas/test/e2e/e2e.isolated.test.ts index 5833082..dde94b3 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: { chest: string; asset: string; amount: number }[], + expected: { account: string; asset: string; amount: number }[], ) { const balances = await Promise.all( - expected.map(({ chest, asset }) => toolbox.getBalance(chest, asset)), + expected.map(({ account, asset }) => toolbox.getBalance(account, 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 chestId = toolbox.client.pas.deriveChestAddress(toolbox.address()); + const accountId = toolbox.client.pas.deriveAccountAddress(toolbox.address()); const suiTypeName = normalizeStructTag('0x2::sui::SUI').toString(); - const { balance } = await toolbox.getBalance(chestId, suiTypeName); + const { balance } = await toolbox.getBalance(accountId, suiTypeName); expect(Number(balance.balance)).toBe(0); - // Transfer 1 SUI to the chest. + // Transfer 1 SUI to the account. 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(chestId)], + arguments: [into_balance, fundTransferTx.pure.address(accountId)], typeArguments: [suiTypeName], }); await toolbox.executeTransaction(fundTransferTx); - // Create the chest for the address. - await toolbox.createChestForAddress(toolbox.address()); + // Create the account for the address. + await toolbox.createAccountForAddress(toolbox.address()); - const { balance: chestBalanceAfterTransfer } = await toolbox.getBalance(chestId, suiTypeName); - expect(Number(chestBalanceAfterTransfer.balance)).toBe(1_000_000_000); + const { balance: accountBalanceAfterTransfer } = await toolbox.getBalance(accountId, suiTypeName); + expect(Number(accountBalanceAfterTransfer.balance)).toBe(1_000_000_000); // try to do an unlock but it should fail because `policy` for Sui does not exist. const tx = new Transaction(); @@ -84,11 +84,11 @@ describe.concurrent( await toolbox.executeTransaction(unlockTx); - const { balance: chestBalanceAfterUnlock } = await toolbox.getBalance(chestId, suiTypeName); - expect(Number(chestBalanceAfterUnlock.balance)).toBe(0); + const { balance: accountBalanceAfterUnlock } = await toolbox.getBalance(accountId, suiTypeName); + expect(Number(accountBalanceAfterUnlock.balance)).toBe(0); }); - it('Should be able to transfer between chests, going through the policy of the issuer;', async () => { + it('Should be able to transfer between accounts, going through the policy of the issuer;', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createPolicy(); @@ -96,17 +96,17 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromChestId = toolbox.client.pas.deriveChestAddress(from); - const toChestId = toolbox.client.pas.deriveChestAddress(to); + const fromAccountId = toolbox.client.pas.deriveAccountAddress(from); + const toAccountId = toolbox.client.pas.deriveAccountAddress(to); - await toolbox.createChestForAddress(from); - await toolbox.createChestForAddress(to); + await toolbox.createAccountForAddress(from); + await toolbox.createAccountForAddress(to); - await demoUsd.mintFromFaucetInto(100, fromChestId); + await demoUsd.mintFromFaucetInto(100, fromAccountId); const [{ balance: fromBalanceBefore }, { balance: toBalanceBefore }] = await Promise.all([ - toolbox.getBalance(fromChestId, demoUsd.demoUsdAssetType), - toolbox.getBalance(toChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(fromAccountId, demoUsd.demoUsdAssetType), + toolbox.getBalance(toAccountId, 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(fromChestId, demoUsd.demoUsdAssetType), - toolbox.getBalance(toChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(fromAccountId, demoUsd.demoUsdAssetType), + toolbox.getBalance(toAccountId, 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 chest if it does not exist ahead of time', async () => { + it('Should be able to create the recipient account if it does not exist ahead of time', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createPolicy(); @@ -141,15 +141,15 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromChestId = toolbox.client.pas.deriveChestAddress(from); - const toChestId = toolbox.client.pas.deriveChestAddress(to); + const fromAccountId = toolbox.client.pas.deriveAccountAddress(from); + const toAccountId = toolbox.client.pas.deriveAccountAddress(to); - await demoUsd.mintFromFaucetInto(100, fromChestId); - await toolbox.createChestForAddress(from); + await demoUsd.mintFromFaucetInto(100, fromAccountId); + await toolbox.createAccountForAddress(from); await expect( toolbox.client.core.getObject({ - objectId: toChestId, + objectId: toAccountId, }), ).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: toChestId, + objectId: toAccountId, }); expect(responseAfter.object).toBeDefined(); }); - it('Should deduplicate chest creation when multiple intents reference the same non-existent chests', async () => { + it('Should deduplicate account creation when multiple intents reference the same non-existent accounts', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createPolicy(); @@ -182,37 +182,37 @@ describe.concurrent( const sender = toolbox.address(); const receiver = normalizeSuiAddress('0xB2'); - const senderChestId = toolbox.client.pas.deriveChestAddress(sender); - const receiverChestId = toolbox.client.pas.deriveChestAddress(receiver); + const senderAccountId = toolbox.client.pas.deriveAccountAddress(sender); + const receiverAccountId = toolbox.client.pas.deriveAccountAddress(receiver); - // Verify neither chest exists. - await expect(toolbox.client.core.getObject({ objectId: senderChestId })).rejects.toThrowError( + // Verify neither account exists. + await expect(toolbox.client.core.getObject({ objectId: senderAccountId })).rejects.toThrowError( 'not found', ); await expect( - toolbox.client.core.getObject({ objectId: receiverChestId }), + toolbox.client.core.getObject({ objectId: receiverAccountId }), ).rejects.toThrowError('not found'); - // Mint funds directly into the sender chest's address (balance::send_funds - // works even before the chest object exists). - await demoUsd.mintFromFaucetInto(200, senderChestId); + // Mint funds directly into the sender account's address (balance::send_funds + // works even before the account object exists). + await demoUsd.mintFromFaucetInto(200, senderAccountId); // Build a single PTB that: - // 1. Implicitly creates the sender chest (via chestForAddress) + // 1. Implicitly creates the sender account (via accountForAddress) // 2. Has an intermediate non-PAS moveCall (a no-op) - // 3. Transfers 50 DEMO_USD from sender -> receiver (receiver chest created implicitly) + // 3. Transfers 50 DEMO_USD from sender -> receiver (receiver account created implicitly) // 4. Has another intermediate non-PAS moveCall - // 5. Transfers another 50 DEMO_USD from sender -> receiver (same chests, no re-creation) + // 5. Transfers another 50 DEMO_USD from sender -> receiver (same accounts, no re-creation) const tx = new Transaction(); - // (1) chestForAddress for sender -- forces implicit creation - tx.add(toolbox.client.pas.tx.chestForAddress(sender)); + // (1) accountForAddress for sender -- forces implicit creation + tx.add(toolbox.client.pas.tx.accountForAddress(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 chest does not exist) + // (3) First transfer: sender -> receiver (receiver account does not exist) tx.add( toolbox.client.pas.tx.sendBalance({ 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 chests already created in this PTB) + // (5) Second transfer: sender -> receiver (both accounts already created in this PTB) tx.add( toolbox.client.pas.tx.sendBalance({ from: sender, @@ -238,18 +238,18 @@ describe.concurrent( await toolbox.executeTransaction(tx); - // Verify both chests now exist. + // Verify both accounts now exist. const [senderObj, receiverObj] = await Promise.all([ - toolbox.client.core.getObject({ objectId: senderChestId }), - toolbox.client.core.getObject({ objectId: receiverChestId }), + toolbox.client.core.getObject({ objectId: senderAccountId }), + toolbox.client.core.getObject({ objectId: receiverAccountId }), ]); 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(senderChestId, demoUsd.demoUsdAssetType), - toolbox.getBalance(receiverChestId, demoUsd.demoUsdAssetType), + toolbox.getBalance(senderAccountId, demoUsd.demoUsdAssetType), + toolbox.getBalance(receiverAccountId, 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 fromChestId = toolbox.client.pas.deriveChestAddress(from); + const fromAccountId = toolbox.client.pas.deriveAccountAddress(from); - await toolbox.createChestForAddress(from); - await toolbox.createChestForAddress(to); - await demoUsd.mintFromFaucetInto(15_000, fromChestId); + await toolbox.createAccountForAddress(from); + await toolbox.createAccountForAddress(to); + await demoUsd.mintFromFaucetInto(15_000, fromAccountId); const tx = new Transaction(); tx.add( @@ -286,16 +286,16 @@ describe.concurrent( ); }); - it('self-transfer is rejected (same chest cannot be borrowed mutably twice)', async () => { + it('self-transfer is rejected (same account cannot be borrowed mutably twice)', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createPolicy(); const addr = toolbox.address(); - const chestId = toolbox.client.pas.deriveChestAddress(addr); + const accountId = toolbox.client.pas.deriveAccountAddress(addr); - await toolbox.createChestForAddress(addr); - await demoUsd.mintFromFaucetInto(10, chestId); + await toolbox.createAccountForAddress(addr); + await demoUsd.mintFromFaucetInto(10, accountId); const tx = new Transaction(); tx.add( @@ -309,14 +309,14 @@ describe.concurrent( const resp = await simulateFailingTransaction(toolbox, tx); expect(resp.FailedTransaction).toBeDefined(); - // Same chest passed as both &mut sender and &mut receiver -- Move rejects + // Same account 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 chests, if there are not enough funds in the source chest', async () => { + it('Should fail to transfer between accounts, if there are not enough funds in the source account', async () => { const toolbox = await setupToolbox(); const demoUsd = new DemoUsdTestHelpers(toolbox); await demoUsd.createPolicy(); @@ -324,8 +324,8 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - await toolbox.createChestForAddress(from); - await toolbox.createChestForAddress(to); + await toolbox.createAccountForAddress(from); + await toolbox.createAccountForAddress(to); const transaction = new Transaction(); transaction.add( @@ -358,11 +358,11 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x3'); - const fromChestId = toolbox.client.pas.deriveChestAddress(from); + const fromAccountId = toolbox.client.pas.deriveAccountAddress(from); - await toolbox.createChestForAddress(from); - await toolbox.createChestForAddress(to); - await demoUsd.mintFromFaucetInto(15_000, fromChestId); + await toolbox.createAccountForAddress(from); + await toolbox.createAccountForAddress(to); + await demoUsd.mintFromFaucetInto(15_000, fromAccountId); await demoUsd.upgradeToV2(); @@ -378,7 +378,7 @@ describe.concurrent( await toolbox.executeTransaction(tx); const { balance } = await toolbox.getBalance( - toolbox.client.pas.deriveChestAddress(to), + toolbox.client.pas.deriveAccountAddress(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 senderChestId = toolbox.client.pas.deriveChestAddress(sender); - const receiverChestId = toolbox.client.pas.deriveChestAddress(receiver); + const senderAccountId = toolbox.client.pas.deriveAccountAddress(sender); + const receiverAccountId = toolbox.client.pas.deriveAccountAddress(receiver); - await asset1.mintFromFaucetInto(500, senderChestId); - await asset2.mintFromFaucetInto(800, senderChestId); + await asset1.mintFromFaucetInto(500, senderAccountId); + await asset2.mintFromFaucetInto(800, senderAccountId); - // --- First PTB: transfers both asset types, implicitly creates receiver chest --- + // --- First PTB: transfers both asset types, implicitly creates receiver account --- const tx1 = new Transaction(); tx1.add( toolbox.client.pas.tx.sendBalance({ @@ -422,16 +422,16 @@ describe.concurrent( ); await toolbox.executeTransaction(tx1); - const receiverObj = await toolbox.client.core.getObject({ objectId: receiverChestId }); + const receiverObj = await toolbox.client.core.getObject({ objectId: receiverAccountId }); expect(receiverObj.object).toBeDefined(); await expectBalances(toolbox, [ - { 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 }, + { account: senderAccountId, asset: asset1.demoUsdAssetType, amount: 380 }, + { account: senderAccountId, asset: asset2.demoUsdAssetType, amount: 450 }, + { account: receiverAccountId, asset: asset1.demoUsdAssetType, amount: 120 }, + { account: receiverAccountId, asset: asset2.demoUsdAssetType, amount: 350 }, ]); - // --- Second PTB: both chests already exist, different amounts --- + // --- Second PTB: both accounts already exist, different amounts --- const tx2 = new Transaction(); tx2.add( toolbox.client.pas.tx.sendBalance({ @@ -452,10 +452,10 @@ describe.concurrent( await toolbox.executeTransaction(tx2); await expectBalances(toolbox, [ - { 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 }, + { account: senderAccountId, asset: asset1.demoUsdAssetType, amount: 300 }, + { account: senderAccountId, asset: asset2.demoUsdAssetType, amount: 300 }, + { account: receiverAccountId, asset: asset1.demoUsdAssetType, amount: 200 }, + { account: receiverAccountId, asset: asset2.demoUsdAssetType, amount: 500 }, ]); }); @@ -466,11 +466,11 @@ describe.concurrent( const from = toolbox.address(); const to = normalizeSuiAddress('0x2'); - const fromChestId = toolbox.client.pas.deriveChestAddress(from); + const fromAccountId = toolbox.client.pas.deriveAccountAddress(from); - await toolbox.createChestForAddress(from); - await toolbox.createChestForAddress(to); - await demoUsd.mintFromFaucetInto(10, fromChestId); + await toolbox.createAccountForAddress(from); + await toolbox.createAccountForAddress(to); + await demoUsd.mintFromFaucetInto(10, fromAccountId); await demoUsd.upgradeToV2(); diff --git a/sdk/pas/test/e2e/e2e.shared.test.ts b/sdk/pas/test/e2e/e2e.shared.test.ts index 9dc42c3..a7d8f2d 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 { Chest } from '../../src/contracts/pas/chest.js'; +import { Account } from '../../src/contracts/pas/account.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.createChestForAddress(address); - const chestId = toolbox.client.pas.deriveChestAddress(address); - await demoUsd.mintFromFaucetInto(100, chestId); + await toolbox.createAccountForAddress(address); + const accountId = toolbox.client.pas.deriveAccountAddress(address); + await demoUsd.mintFromFaucetInto(100, accountId); 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 chests', async () => { - const chestObjectId = toolbox.client.pas.deriveChestAddress(toolbox.address()); - await toolbox.createChestForAddress(toolbox.address()); + it('derivations work as expected for accounts', async () => { + const accountObjectId = toolbox.client.pas.deriveAccountAddress(toolbox.address()); + await toolbox.createAccountForAddress(toolbox.address()); - const { object: chestObject } = await toolbox.client.core.getObject({ - objectId: chestObjectId, + const { object: accountObject } = await toolbox.client.core.getObject({ + objectId: accountObjectId, include: { content: true }, }); - expect(chestObject).toBeDefined(); + expect(accountObject).toBeDefined(); - const parsed = Chest.parse(chestObject.content!); + const parsed = Account.parse(accountObject.content!); expect(normalizeSuiAddress(parsed.owner)).toBe(normalizeSuiAddress(toolbox.address())); - expect(chestObject.type).toBe( - `${toolbox.client.pas.getPackageConfig().packageId}::chest::Chest`, + expect(accountObject.type).toBe( + `${toolbox.client.pas.getPackageConfig().packageId}::account::Account`, ); }); diff --git a/sdk/pas/test/e2e/setup.ts b/sdk/pas/test/e2e/setup.ts index a63646c..4ef78c1 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 chest for a given address. - async createChestForAddress(address: string) { + // Creates a account for a given address. + async createAccountForAddress(address: string) { const tx = new Transaction(); - tx.add(this.client.pas.tx.chestForAddress(address)); + tx.add(this.client.pas.tx.accountForAddress(address)); return this.executeTransaction(tx); } diff --git a/sdk/pas/test/unit/derivation.test.ts b/sdk/pas/test/unit/derivation.test.ts index fcc3254..26535bb 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 { deriveChestAddress, derivePolicyAddress } from '../../src/derivation.js'; +import { deriveAccountAddress, derivePolicyAddress } 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('deriveChestAddress', () => { - it('should derive chest address for owner 0x456', () => { - const chestId = deriveChestAddress('0x456', packageConfig); - expect(chestId).toMatchInlineSnapshot( + describe('deriveAccountAddress', () => { + it('should derive account address for owner 0x456', () => { + const accountId = deriveAccountAddress('0x456', packageConfig); + expect(accountId).toMatchInlineSnapshot( `"0x669fe85c5c4c4df6780f1e8680a8616af7fdca99559a5204e72cf092f3eaadbc"`, ); }); - it('should derive chest address for owner 0x789', () => { - const chestId = deriveChestAddress('0x789', packageConfig); - expect(chestId).toMatchInlineSnapshot( + it('should derive account address for owner 0x789', () => { + const accountId = deriveAccountAddress('0x789', packageConfig); + expect(accountId).toMatchInlineSnapshot( `"0xc50c691dc80963539896ff8c261b7c046eeebc84fc9e9d0278ef5381b31b3fa8"`, ); }); - it('should derive chest address for different namespace', () => { + it('should derive account address for different namespace', () => { const config = { ...packageConfig, namespaceId: '0xdef' }; - const chestId = deriveChestAddress('0x456', config); - expect(chestId).toMatchInlineSnapshot( + const accountId = deriveAccountAddress('0x456', config); + expect(accountId).toMatchInlineSnapshot( `"0x219e8547860e5fe3f526453e108763965fbb0d7f391c1ba977c5cc5ea74be1e1"`, ); }); it('should normalize addresses correctly', () => { - const chestId1 = deriveChestAddress('0x1', packageConfig); - const chestId2 = deriveChestAddress( + const accountId1 = deriveAccountAddress('0x1', packageConfig); + const accountId2 = deriveAccountAddress( '0x0000000000000000000000000000000000000000000000000000000000000001', packageConfig, ); - expect(chestId1).toBe(chestId2); - expect(chestId1).toMatchInlineSnapshot( + expect(accountId1).toBe(accountId2); + expect(accountId1).toMatchInlineSnapshot( `"0xed31e9da3671b44b36eb216e5fdbacd42e32fc060e74def41a5fca3f5aba2000"`, ); }); - it('should derive chest for object owner', () => { - const chestId = deriveChestAddress( + it('should derive account for object owner', () => { + const accountId = deriveAccountAddress( '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', packageConfig, ); - expect(chestId).toMatchInlineSnapshot( + expect(accountId).toMatchInlineSnapshot( `"0x3c76832eb19537437d093c4bf1264e9e371f168f884295764f2f4a370fb5c898"`, ); }); From b8c8716671223c72bd6a8e5de11b54dc8939c3c3 Mon Sep 17 00:00:00 2001 From: Manos Liolios Date: Wed, 11 Mar 2026 13:26:22 +0200 Subject: [PATCH 2/2] fix derivation tests --- packages/pas/sources/requests/unlock_funds.move | 6 +++++- sdk/pas/src/resolution.ts | 5 ++++- sdk/pas/test/unit/derivation.test.ts | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/pas/sources/requests/unlock_funds.move b/packages/pas/sources/requests/unlock_funds.move index 9335747..4ad5ffd 100644 --- a/packages/pas/sources/requests/unlock_funds.move +++ b/packages/pas/sources/requests/unlock_funds.move @@ -59,6 +59,10 @@ public fun resolve(request: Request>, policy: &Policy(owner: address, account_id: ID, funds: T): Request> { +public(package) fun new( + owner: address, + account_id: ID, + funds: T, +): Request> { request::new(UnlockFunds { owner, account_id, funds }) } diff --git a/sdk/pas/src/resolution.ts b/sdk/pas/src/resolution.ts index 88bba7a..ccccb70 100644 --- a/sdk/pas/src/resolution.ts +++ b/sdk/pas/src/resolution.ts @@ -196,7 +196,10 @@ export function buildMoveCallCommandFromTemplate( ); } } else if (arg.Input.Ext) { - resolvedArgs.push(resolveRawPasRequest(args, arg.Input.Ext)); + resolvedArgs.push(resolveRawPasRequest(args, { + _namespace: arg.Input.Ext.namespace, + value: arg.Input.Ext.value, + })); } else { throw new PASClientError(`Unsupported input kind: ${arg.Input.$kind}`); } diff --git a/sdk/pas/test/unit/derivation.test.ts b/sdk/pas/test/unit/derivation.test.ts index 26535bb..6dbc4aa 100644 --- a/sdk/pas/test/unit/derivation.test.ts +++ b/sdk/pas/test/unit/derivation.test.ts @@ -16,14 +16,14 @@ describe('PAS Object Derivation', () => { it('should derive account address for owner 0x456', () => { const accountId = deriveAccountAddress('0x456', packageConfig); expect(accountId).toMatchInlineSnapshot( - `"0x669fe85c5c4c4df6780f1e8680a8616af7fdca99559a5204e72cf092f3eaadbc"`, + `"0x9605073416559b859b4dd1da95bf2dabf4fa950fd5e25b577cc8b7ff8e02d064"`, ); }); it('should derive account address for owner 0x789', () => { const accountId = deriveAccountAddress('0x789', packageConfig); expect(accountId).toMatchInlineSnapshot( - `"0xc50c691dc80963539896ff8c261b7c046eeebc84fc9e9d0278ef5381b31b3fa8"`, + `"0xa4f66e119756ac7f2b17c8b578f09269eaac2c7116abc6ffa5eadd080cacbfb5"`, ); }); @@ -31,7 +31,7 @@ describe('PAS Object Derivation', () => { const config = { ...packageConfig, namespaceId: '0xdef' }; const accountId = deriveAccountAddress('0x456', config); expect(accountId).toMatchInlineSnapshot( - `"0x219e8547860e5fe3f526453e108763965fbb0d7f391c1ba977c5cc5ea74be1e1"`, + `"0xdc173ff5543875bbb241fa9056aae7fbad0d77f14496d32b2a9d3e4bfaaa6ac8"`, ); }); @@ -44,7 +44,7 @@ describe('PAS Object Derivation', () => { expect(accountId1).toBe(accountId2); expect(accountId1).toMatchInlineSnapshot( - `"0xed31e9da3671b44b36eb216e5fdbacd42e32fc060e74def41a5fca3f5aba2000"`, + `"0xe078596559d864cf753670c3114ad6b0e61a56c563f41648cf2832bd78bdfa5d"`, ); }); @@ -54,7 +54,7 @@ describe('PAS Object Derivation', () => { packageConfig, ); expect(accountId).toMatchInlineSnapshot( - `"0x3c76832eb19537437d093c4bf1264e9e371f168f884295764f2f4a370fb5c898"`, + `"0x3df40ec902430b690b682ecdf489bf8884bdc963c79f677db17f21b7a0e7a0b9"`, ); }); });