diff --git a/.changeset/little-papers-notice.md b/.changeset/little-papers-notice.md new file mode 100644 index 000000000..0ba683536 --- /dev/null +++ b/.changeset/little-papers-notice.md @@ -0,0 +1,5 @@ +--- +'@openzeppelin/wizard-common': patch +--- + +Modify tooltip descriptions regarding default implementations to fit the changes introduced with v0.6.0 diff --git a/.changeset/pink-eyes-judge.md b/.changeset/pink-eyes-judge.md new file mode 100644 index 000000000..1cdd3710f --- /dev/null +++ b/.changeset/pink-eyes-judge.md @@ -0,0 +1,10 @@ +--- +'@openzeppelin/wizard-stellar': minor +--- + +Refactor Stellar contracts to match the latest v0.6.0 + - **Breaking changes**: + - Use OpenZeppelin Stellar Soroban Contracts v0.6.0 + - Use `MuxedAddress` for fungible transfer function + - Change order of parameters in access control + - Change default fungible decimals to 7 diff --git a/packages/common/src/ai/descriptions/stellar.ts b/packages/common/src/ai/descriptions/stellar.ts index cc151bcc2..3a0c7fd49 100644 --- a/packages/common/src/ai/descriptions/stellar.ts +++ b/packages/common/src/ai/descriptions/stellar.ts @@ -13,7 +13,7 @@ export const stellarCommonDescriptions = { access: 'The type of access control to provision. Ownable is a simple mechanism with a single account authorized for all privileged actions. Roles is a flexible mechanism with a separate role for each privileged action. A role can have many authorized accounts.', explicitImplementations: - 'Whether the contract should use explicit trait implementations instead of using the #[default_impl] macro to auto-generate trait method bodies.', + 'Whether the contract should use explicit trait implementations instead of using the default ones provided by the library.', }; export const stellarFungibleDescriptions = { diff --git a/packages/core/stellar/src/add-pausable.ts b/packages/core/stellar/src/add-pausable.ts index d5cf968fd..0ac7fedb2 100644 --- a/packages/core/stellar/src/add-pausable.ts +++ b/packages/core/stellar/src/add-pausable.ts @@ -7,7 +7,6 @@ import { defineFunctions } from './utils/define-functions'; export function addPausable(c: ContractBuilder, access: Access, explicitImplementations: boolean) { c.addUseClause('stellar_contract_utils::pausable', 'self', { alias: 'pausable' }); c.addUseClause('stellar_contract_utils::pausable', 'Pausable'); - if (!explicitImplementations) c.addUseClause('stellar_macros', 'default_impl'); const pausableTrait = { traitName: 'Pausable', diff --git a/packages/core/stellar/src/contract.test.ts.md b/packages/core/stellar/src/contract.test.ts.md index 40c6b6b58..a45f9d867 100644 --- a/packages/core/stellar/src/contract.test.ts.md +++ b/packages/core/stellar/src/contract.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ #[contract]␊ @@ -21,7 +21,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ #[contract]␊ @@ -40,7 +40,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ #[contract]␊ @@ -59,7 +59,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ #[contract]␊ @@ -81,7 +81,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ #[contract]␊ @@ -103,7 +103,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use some::library::SomeLibrary;␊ @@ -117,7 +117,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use some::library::{Misc, SomeLibrary};␊ @@ -131,7 +131,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use another::library::{self as custom1, self as custom2, AnotherLibrary};␊ @@ -146,7 +146,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ ␊ //! Some documentation␊ #![no_std]␊ @@ -160,7 +160,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::contractmeta;␊ @@ -176,7 +176,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::contractmeta;␊ @@ -193,7 +193,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ ␊ //! Some documentation␊ #![no_std]␊ @@ -212,7 +212,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::contractmeta;␊ diff --git a/packages/core/stellar/src/contract.test.ts.snap b/packages/core/stellar/src/contract.test.ts.snap index bd748d120..81d716279 100644 Binary files a/packages/core/stellar/src/contract.test.ts.snap and b/packages/core/stellar/src/contract.test.ts.snap differ diff --git a/packages/core/stellar/src/fungible.test.ts.md b/packages/core/stellar/src/fungible.test.ts.md index a97f0739c..7818a875e 100644 --- a/packages/core/stellar/src/fungible.test.ts.md +++ b/packages/core/stellar/src/fungible.test.ts.md @@ -9,11 +9,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -22,12 +23,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -39,11 +39,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -52,12 +53,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -67,8 +67,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyToken {}␊ ` @@ -77,13 +76,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -92,18 +93,17 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -117,6 +117,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -133,10 +136,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## fungible burnable pausable @@ -144,13 +143,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -159,18 +160,17 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -184,7 +184,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -201,6 +201,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -217,10 +220,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## fungible preminted @@ -228,11 +227,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -241,13 +241,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, recipient: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 1000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 10000000000);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -259,11 +258,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -272,12 +272,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -289,11 +288,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -302,12 +302,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -319,12 +318,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::default_impl;␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -333,13 +333,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -349,8 +348,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyToken {}␊ ` @@ -359,12 +357,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::access_control::{self as access_control, AccessControl};␊ - use stellar_macros::default_impl;␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -373,13 +372,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, admin: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ access_control::set_admin(e, &admin);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -389,8 +387,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl AccessControl for MyToken {}␊ ` @@ -399,13 +396,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -414,8 +413,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 20000000000);␊ ownable::set_owner(e, &owner);␊ }␊ ␊ @@ -426,13 +425,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -446,7 +444,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -463,6 +461,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -479,10 +480,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## fungible full - roles @@ -490,14 +487,16 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String, Symbol};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::access_control::{self as access_control, AccessControl};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ use stellar_contract_utils::upgradeable::UpgradeableInternal;␊ - use stellar_macros::{default_impl, only_role, Upgradeable, when_not_paused};␊ + use stellar_macros::{only_role, Upgradeable, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[derive(Upgradeable)]␊ @@ -514,12 +513,12 @@ Generated by [AVA](https://avajs.dev). upgrader: Address,␊ minter: Address,␊ ) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 20000000000);␊ access_control::set_admin(e, &admin);␊ - access_control::grant_role_no_auth(e, &admin, &pauser, &Symbol::new(e, "pauser"));␊ - access_control::grant_role_no_auth(e, &admin, &upgrader, &Symbol::new(e, "upgrader"));␊ - access_control::grant_role_no_auth(e, &admin, &minter, &Symbol::new(e, "minter"));␊ + access_control::grant_role_no_auth(e, &pauser, &Symbol::new(e, "pauser"), &admin);␊ + access_control::grant_role_no_auth(e, &upgrader, &Symbol::new(e, "upgrader"), &admin);␊ + access_control::grant_role_no_auth(e, &minter, &Symbol::new(e, "minter"), &admin);␊ }␊ ␊ #[only_role(caller, "minter")]␊ @@ -529,13 +528,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -549,7 +547,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -568,11 +566,14 @@ Generated by [AVA](https://avajs.dev). ␊ impl UpgradeableInternal for MyToken {␊ fn _require_auth(e: &Env, operator: &Address) {␊ - access_control::ensure_role(e, operator, &Symbol::new(e, "upgrader"));␊ + access_control::ensure_role(e, &Symbol::new(e, "upgrader"), operator);␊ operator.require_auth();␊ }␊ }␊ ␊ + #[contractimpl(contracttrait)]␊ + impl AccessControl for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -589,10 +590,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl AccessControl for MyToken {}␊ ` ## fungible full - complex name @@ -600,14 +597,16 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ use stellar_contract_utils::upgradeable::UpgradeableInternal;␊ - use stellar_macros::{default_impl, only_owner, Upgradeable, when_not_paused};␊ + use stellar_macros::{only_owner, Upgradeable, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[derive(Upgradeable)]␊ @@ -617,8 +616,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl CustomToken {␊ pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "Custom $ Token"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "Custom $ Token"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 20000000000);␊ ownable::set_owner(e, &owner);␊ }␊ ␊ @@ -629,13 +628,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for CustomToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -649,7 +647,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for CustomToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -672,6 +670,9 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for CustomToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for CustomToken {␊ fn paused(e: &Env) -> bool {␊ @@ -688,10 +689,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for CustomToken {}␊ ` ## fungible explicit trait implementations @@ -699,10 +696,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -711,7 +710,7 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ }␊ }␊ ␊ @@ -731,7 +730,7 @@ Generated by [AVA](https://avajs.dev). Self::ContractType::allowance(e, &owner, &spender)␊ }␊ ␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ diff --git a/packages/core/stellar/src/fungible.test.ts.snap b/packages/core/stellar/src/fungible.test.ts.snap index 84a1df52a..57c61bb47 100644 Binary files a/packages/core/stellar/src/fungible.test.ts.snap and b/packages/core/stellar/src/fungible.test.ts.snap differ diff --git a/packages/core/stellar/src/fungible.ts b/packages/core/stellar/src/fungible.ts index ab4d20135..b79b4d2ed 100644 --- a/packages/core/stellar/src/fungible.ts +++ b/packages/core/stellar/src/fungible.ts @@ -97,24 +97,24 @@ function addBase( explicitImplementations: boolean, ) { // Set metadata - c.addConstructorCode(`Base::set_metadata(e, 18, String::from_str(e, "${name}"), String::from_str(e, "${symbol}"));`); + c.addConstructorCode(`Base::set_metadata(e, 7, String::from_str(e, "${name}"), String::from_str(e, "${symbol}"));`); // Set token functions c.addUseClause('stellar_tokens::fungible', 'Base'); c.addUseClause('stellar_tokens::fungible', 'FungibleToken'); - if (!explicitImplementations) c.addUseClause('stellar_macros', 'default_impl'); c.addUseClause('soroban_sdk', 'contract'); c.addUseClause('soroban_sdk', 'contractimpl'); c.addUseClause('soroban_sdk', 'String'); + c.addUseClause('soroban_sdk', 'Symbol'); c.addUseClause('soroban_sdk', 'Env'); - if (explicitImplementations || pausable) { - c.addUseClause('soroban_sdk', 'Address'); - } + c.addUseClause('soroban_sdk', 'Address'); + c.addUseClause('soroban_sdk', 'MuxedAddress'); + c.addUseClause('soroban_sdk', 'Vec'); const fungibleTokenTrait = { traitName: 'FungibleToken', structName: c.name, - tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], assocType: 'type ContractType = Base;', }; @@ -134,7 +134,6 @@ function addBase( } function addMintable(c: ContractBuilder, access: Access, pausable: boolean, explicitImplementations: boolean) { - c.addUseClause('soroban_sdk', 'Address'); switch (access) { case false: break; @@ -178,12 +177,11 @@ function addMintable(c: ContractBuilder, access: Access, pausable: boolean, expl function addBurnable(c: ContractBuilder, pausable: boolean, explicitImplementations: boolean) { c.addUseClause('stellar_tokens::fungible', 'burnable::FungibleBurnable'); - c.addUseClause('soroban_sdk', 'Address'); const fungibleBurnableTrait = { traitName: 'FungibleBurnable', structName: c.name, - tags: ['contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], section: 'Extensions', }; @@ -197,8 +195,6 @@ function addBurnable(c: ContractBuilder, pausable: boolean, explicitImplementati c.addFunctionTag(functions.burn_from, 'when_not_paused', fungibleBurnableTrait); } else if (explicitImplementations) c.addTraitForEachFunctions(fungibleBurnableTrait, fungibleBurnableFunctions); else { - // prepend '#[default_impl]' - fungibleBurnableTrait.tags.unshift('default_impl'); c.addTraitImplBlock(fungibleBurnableTrait); } } @@ -214,9 +210,7 @@ function addPremint(c: ContractBuilder, amount: string) { } // TODO: handle signed int? - const premintAbsolute = toUint(getInitialSupply(amount, 18), 'premint', 'u128'); - - c.addUseClause('soroban_sdk', 'Address'); + const premintAbsolute = toUint(getInitialSupply(amount, 7), 'premint', 'u128'); c.addConstructorArgument({ name: 'recipient', type: 'Address' }); c.addConstructorCode(`Base::mint(e, &recipient, ${premintAbsolute});`); @@ -285,7 +279,7 @@ export const functions = defineFunctions({ args: [ getSelfArg(), { name: 'from', type: 'Address' }, - { name: 'to', type: 'Address' }, + { name: 'to', type: 'MuxedAddress' }, { name: 'amount', type: 'i128' }, ], code: ['Self::ContractType::transfer(e, &from, &to, amount)'], diff --git a/packages/core/stellar/src/non-fungible.test.ts.md b/packages/core/stellar/src/non-fungible.test.ts.md index 462dc1400..0b5d7af06 100644 --- a/packages/core/stellar/src/non-fungible.test.ts.md +++ b/packages/core/stellar/src/non-fungible.test.ts.md @@ -9,11 +9,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[contract]␊ @@ -29,8 +28,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -42,11 +40,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊ ␊ #[contract]␊ @@ -62,8 +59,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -73,8 +69,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleBurnable for MyToken {}␊ ` @@ -83,13 +78,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[contract]␊ @@ -106,8 +101,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -126,6 +120,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -142,10 +139,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## non-fungible burnable pausable @@ -153,13 +146,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊ ␊ #[contract]␊ @@ -176,8 +169,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -196,7 +188,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, token_id: u32) {␊ @@ -213,6 +205,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -229,10 +224,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## non-fungible mintable @@ -240,12 +231,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::{default_impl, only_owner};␊ + use stellar_macros::only_owner;␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[contract]␊ @@ -267,8 +258,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -278,8 +268,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyToken {}␊ ` @@ -288,11 +277,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_tokens::non_fungible::{␊ Base, enumerable::{NonFungibleEnumerable, Enumerable}, NonFungibleToken␊ };␊ @@ -310,8 +298,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Enumerable;␊ ␊ @@ -321,8 +308,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleEnumerable for MyToken {}␊ ` @@ -331,12 +317,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::{default_impl, only_owner};␊ + use stellar_macros::only_owner;␊ use stellar_tokens::non_fungible::{␊ Base, consecutive::{NonFungibleConsecutive, Consecutive}, NonFungibleToken␊ };␊ @@ -360,8 +346,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Consecutive;␊ ␊ @@ -378,8 +363,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyToken {}␊ ` @@ -388,12 +372,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::{default_impl, only_owner};␊ + use stellar_macros::only_owner;␊ use stellar_tokens::non_fungible::{␊ Base, burnable::NonFungibleBurnable, consecutive::{NonFungibleConsecutive, Consecutive},␊ NonFungibleToken␊ @@ -418,8 +402,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Consecutive;␊ ␊ @@ -429,19 +412,17 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ - impl NonFungibleConsecutive for MyToken {}␊ + #[contractimpl(contracttrait)]␊ + impl NonFungibleBurnable for MyToken {}␊ ␊ - #[default_impl]␊ #[contractimpl]␊ - impl NonFungibleBurnable for MyToken {}␊ + impl NonFungibleConsecutive for MyToken {}␊ ␊ //␊ // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyToken {}␊ ` @@ -450,13 +431,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::non_fungible::{␊ Base, consecutive::{NonFungibleConsecutive, Consecutive}, NonFungibleToken␊ };␊ @@ -481,8 +462,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Consecutive;␊ ␊ @@ -508,6 +488,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -524,10 +507,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## non-fungible consecutive burnable pausable @@ -535,13 +514,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::non_fungible::{␊ Base, burnable::NonFungibleBurnable, consecutive::{NonFungibleConsecutive, Consecutive},␊ NonFungibleToken␊ @@ -567,8 +546,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Consecutive;␊ ␊ @@ -587,7 +565,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, token_id: u32) {␊ @@ -607,6 +585,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -623,10 +604,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## non-fungible sequential @@ -634,11 +611,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[contract]␊ @@ -654,8 +630,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -667,13 +642,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::upgradeable::UpgradeableInternal;␊ - use stellar_macros::{default_impl, only_owner, Upgradeable};␊ + use stellar_macros::{only_owner, Upgradeable};␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[derive(Upgradeable)]␊ @@ -691,8 +666,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -709,8 +683,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyToken {}␊ ` @@ -719,14 +692,14 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ use stellar_contract_utils::upgradeable::UpgradeableInternal;␊ - use stellar_macros::{default_impl, only_owner, Upgradeable, when_not_paused};␊ + use stellar_macros::{only_owner, Upgradeable, when_not_paused};␊ use stellar_tokens::non_fungible::{␊ Base, burnable::NonFungibleBurnable, enumerable::{NonFungibleEnumerable, Enumerable},␊ NonFungibleToken␊ @@ -753,8 +726,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Enumerable;␊ ␊ @@ -773,7 +745,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleBurnable for MyToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, token_id: u32) {␊ @@ -786,8 +758,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleEnumerable for MyToken {}␊ ␊ //␊ @@ -800,6 +771,9 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyToken {␊ fn paused(e: &Env) -> bool {␊ @@ -816,10 +790,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyToken {}␊ ` ## non-fungible - complex name @@ -827,13 +797,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊ ␊ #[contract]␊ @@ -850,8 +820,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for CustomToken {␊ type ContractType = Base;␊ ␊ @@ -870,7 +839,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleBurnable for CustomToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, token_id: u32) {␊ @@ -887,6 +856,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for CustomToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for CustomToken {␊ fn paused(e: &Env) -> bool {␊ @@ -903,10 +875,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for CustomToken {}␊ ` ## non-fungible explicit trait implementations @@ -914,7 +882,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ @@ -994,11 +962,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊ ␊ #[contract]␊ @@ -1014,8 +981,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl NonFungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ diff --git a/packages/core/stellar/src/non-fungible.test.ts.snap b/packages/core/stellar/src/non-fungible.test.ts.snap index 7c8e15e56..5dab96554 100644 Binary files a/packages/core/stellar/src/non-fungible.test.ts.snap and b/packages/core/stellar/src/non-fungible.test.ts.snap differ diff --git a/packages/core/stellar/src/non-fungible.ts b/packages/core/stellar/src/non-fungible.ts index 1029695a6..dbd2defa2 100644 --- a/packages/core/stellar/src/non-fungible.ts +++ b/packages/core/stellar/src/non-fungible.ts @@ -155,17 +155,16 @@ function addBase( c.addUseClause('stellar_tokens::non_fungible', 'Base'); c.addUseClause('stellar_tokens::non_fungible', 'NonFungibleToken'); if (explicitImplementations) c.addUseClause('stellar_tokens::non_fungible', 'ContractOverrides'); - else c.addUseClause('stellar_macros', 'default_impl'); c.addUseClause('soroban_sdk', 'contract'); c.addUseClause('soroban_sdk', 'contractimpl'); c.addUseClause('soroban_sdk', 'String'); c.addUseClause('soroban_sdk', 'Env'); - if (explicitImplementations || pausable) c.addUseClause('soroban_sdk', 'Address'); + c.addUseClause('soroban_sdk', 'Address'); const nonFungibleTokenTrait = { traitName: 'NonFungibleToken', structName: c.name, - tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], assocType: 'type ContractType = Base;', }; @@ -190,7 +189,7 @@ function addBurnable(c: ContractBuilder, pausable: boolean, explicitImplementati const nonFungibleBurnableTrait = { traitName: 'NonFungibleBurnable', structName: c.name, - tags: ['contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], section: 'Extensions', }; @@ -205,21 +204,17 @@ function addBurnable(c: ContractBuilder, pausable: boolean, explicitImplementati } else if (explicitImplementations) c.addTraitForEachFunctions(nonFungibleBurnableTrait, nonFungibleBurnableFunctions); else { - // prepend '#[default_impl]' - nonFungibleBurnableTrait.tags.unshift('default_impl'); c.addTraitImplBlock(nonFungibleBurnableTrait); } } function addEnumerable(c: ContractBuilder, explicitImplementations: boolean) { c.addUseClause('stellar_tokens::non_fungible', 'enumerable::{NonFungibleEnumerable, Enumerable}'); - if (explicitImplementations) c.addUseClause('soroban_sdk', 'Address'); - else c.addUseClause('stellar_macros', 'default_impl'); const nonFungibleEnumerableTrait = { traitName: 'NonFungibleEnumerable', structName: c.name, - tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], section: 'Extensions', }; if (explicitImplementations) @@ -231,7 +226,6 @@ function addEnumerable(c: ContractBuilder, explicitImplementations: boolean) { function addConsecutive(c: ContractBuilder, pausable: boolean, access: Access, explicitImplementations: boolean) { c.addUseClause('stellar_tokens::non_fungible', 'consecutive::{NonFungibleConsecutive, Consecutive}'); - c.addUseClause('soroban_sdk', 'Address'); const effectiveAccess = access === false ? DEFAULT_ACCESS_CONTROL : access; const nonFungibleConsecutiveTrait = { @@ -274,7 +268,6 @@ function addMintable( access: Access, explicitImplementations: boolean, ) { - c.addUseClause('soroban_sdk', 'Address'); const accessProps = { useMacro: true, role: 'minter', caller: 'caller' }; const effectiveAccess = access === false ? DEFAULT_ACCESS_CONTROL : access; diff --git a/packages/core/stellar/src/set-access-control.ts b/packages/core/stellar/src/set-access-control.ts index e7ee71b74..f9edf362f 100644 --- a/packages/core/stellar/src/set-access-control.ts +++ b/packages/core/stellar/src/set-access-control.ts @@ -29,7 +29,7 @@ export function setAccessControl(c: ContractBuilder, access: Access, explicitImp const ownableTrait = { traitName: 'Ownable', structName: c.name, - tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], section: 'Utils', }; if (explicitImplementations) { @@ -51,7 +51,7 @@ export function setAccessControl(c: ContractBuilder, access: Access, explicitImp const accessControlTrait = { traitName: 'AccessControl', structName: c.name, - tags: explicitImplementations ? ['contractimpl'] : ['default_impl', 'contractimpl'], + tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'], section: 'Utils', }; if (explicitImplementations) { @@ -105,8 +105,9 @@ export function requireAccessControl( if (caller && role) { c.addUseClause('soroban_sdk', 'Symbol'); + c.addUseClause('soroban_sdk', 'Vec'); c.addConstructorArgument({ name: role, type: 'Address' }); - c.addConstructorCode(`access_control::grant_role_no_auth(e, &admin, &${role}, &Symbol::new(e, "${role}"));`); + c.addConstructorCode(`access_control::grant_role_no_auth(e, &${role}, &Symbol::new(e, "${role}"), &admin);`); if (useMacro) { c.addUseClause('stellar_macros', 'only_role'); @@ -114,7 +115,7 @@ export function requireAccessControl( } else { c.addFunctionCodeBefore( fn, - [`access_control::ensure_role(e, ${caller}, &Symbol::new(e, "${role}"));`], + [`access_control::ensure_role(e, &Symbol::new(e, "${role}"), ${caller});`], trait, ); } @@ -162,6 +163,11 @@ const accessControlFunctions = defineFunctions({ returns: 'Option', code: ['access_control::has_role(e, &account, &role)'], }, + get_existing_roles: { + args: [getSelfArg()], + returns: 'Vec', + code: ['access_control::get_existing_roles(e)'], + }, get_role_member_count: { args: [getSelfArg(), { name: 'role', type: 'Symbol' }], returns: 'u32', @@ -185,24 +191,24 @@ const accessControlFunctions = defineFunctions({ grant_role: { args: [ getSelfArg(), - { name: 'caller', type: 'Address' }, { name: 'account', type: 'Address' }, { name: 'role', type: 'Symbol' }, + { name: 'caller', type: 'Address' }, ], - code: ['access_control::grant_role(e, &caller, &account, &role);'], + code: ['access_control::grant_role(e, &account, &role, &caller);'], }, revoke_role: { args: [ getSelfArg(), - { name: 'caller', type: 'Address' }, { name: 'account', type: 'Address' }, { name: 'role', type: 'Symbol' }, + { name: 'caller', type: 'Address' }, ], - code: ['access_control::revoke_role(e, &caller, &account, &role);'], + code: ['access_control::revoke_role(e, &account, &role, &caller);'], }, renounce_role: { - args: [getSelfArg(), { name: 'caller', type: 'Address' }, { name: 'role', type: 'Symbol' }], - code: ['access_control::renounce_role(e, &caller, &role);'], + args: [getSelfArg(), { name: 'role', type: 'Symbol' }, { name: 'caller', type: 'Address' }], + code: ['access_control::renounce_role(e, &role, &caller);'], }, transfer_admin_role: { args: [getSelfArg(), { name: 'new_admin', type: 'Address' }, { name: 'live_until_ledger', type: 'u32' }], diff --git a/packages/core/stellar/src/stablecoin.test.ts.md b/packages/core/stellar/src/stablecoin.test.ts.md index abb7da355..d2225ae65 100644 --- a/packages/core/stellar/src/stablecoin.test.ts.md +++ b/packages/core/stellar/src/stablecoin.test.ts.md @@ -9,11 +9,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -22,12 +23,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -39,11 +39,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -52,12 +53,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -67,8 +67,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {}␊ ` @@ -77,13 +76,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -92,18 +93,17 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -117,6 +117,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -133,10 +136,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyStablecoin {}␊ ` ## stablecoin burnable pausable @@ -144,13 +143,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -159,18 +160,17 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -184,7 +184,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -201,6 +201,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -217,10 +220,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyStablecoin {}␊ ` ## stablecoin preminted @@ -228,11 +227,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -241,13 +241,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, recipient: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 1000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 10000000000);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -259,11 +258,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -272,12 +272,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -289,11 +288,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -302,12 +302,11 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -319,12 +318,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::default_impl;␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -333,13 +333,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -349,8 +348,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyStablecoin {}␊ ` @@ -359,12 +357,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::access_control::{self as access_control, AccessControl};␊ - use stellar_macros::default_impl;␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -373,13 +372,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, admin: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ access_control::set_admin(e, &admin);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = Base;␊ ␊ @@ -389,8 +387,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl AccessControl for MyStablecoin {}␊ ` @@ -399,12 +396,14 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::{default_impl, only_owner};␊ + use stellar_macros::only_owner;␊ use stellar_tokens::fungible::{␊ allowlist::{AllowList, FungibleAllowList}, Base, FungibleToken␊ };␊ @@ -415,13 +414,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = AllowList;␊ ␊ @@ -452,8 +450,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyStablecoin {}␊ ` @@ -462,12 +459,14 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ - use stellar_macros::{default_impl, only_owner};␊ + use stellar_macros::only_owner;␊ use stellar_tokens::fungible::{␊ Base, blocklist::{BlockList, FungibleBlockList}, FungibleToken␊ };␊ @@ -478,13 +477,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = BlockList;␊ ␊ @@ -515,8 +513,7 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl Ownable for MyStablecoin {}␊ ` @@ -525,10 +522,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_macros::only_owner;␊ use stellar_tokens::fungible::{␊ @@ -541,7 +540,7 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ @@ -562,7 +561,7 @@ Generated by [AVA](https://avajs.dev). Self::ContractType::allowance(e, &owner, &spender)␊ }␊ ␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -637,10 +636,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_macros::only_owner;␊ use stellar_tokens::fungible::{␊ @@ -653,7 +654,7 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ ownable::set_owner(e, &owner);␊ }␊ }␊ @@ -674,7 +675,7 @@ Generated by [AVA](https://avajs.dev). Self::ContractType::allowance(e, &owner, &spender)␊ }␊ ␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -749,13 +750,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{␊ allowlist::{AllowList, FungibleAllowList}, Base, burnable::FungibleBurnable, FungibleToken␊ };␊ @@ -766,8 +769,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 20000000000);␊ ownable::set_owner(e, &owner);␊ }␊ ␊ @@ -778,13 +781,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = AllowList;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -815,7 +817,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -832,6 +834,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -848,10 +853,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyStablecoin {}␊ ` ## stablecoin full - ownable, blocklist @@ -859,13 +860,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{␊ Base, blocklist::{BlockList, FungibleBlockList}, burnable::FungibleBurnable, FungibleToken␊ };␊ @@ -876,8 +879,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 20000000000);␊ ownable::set_owner(e, &owner);␊ }␊ ␊ @@ -888,13 +891,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = BlockList;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -925,7 +927,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -942,6 +944,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -958,10 +963,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for MyStablecoin {}␊ ` ## stablecoin full - roles, allowlist @@ -969,13 +970,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String, Symbol};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::access_control::{self as access_control, AccessControl};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_role, when_not_paused};␊ + use stellar_macros::{only_role, when_not_paused};␊ use stellar_tokens::fungible::{␊ allowlist::{AllowList, FungibleAllowList}, Base, burnable::FungibleBurnable, FungibleToken␊ };␊ @@ -993,12 +996,12 @@ Generated by [AVA](https://avajs.dev). minter: Address,␊ manager: Address,␊ ) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 20000000000);␊ access_control::set_admin(e, &admin);␊ - access_control::grant_role_no_auth(e, &admin, &pauser, &Symbol::new(e, "pauser"));␊ - access_control::grant_role_no_auth(e, &admin, &minter, &Symbol::new(e, "minter"));␊ - access_control::grant_role_no_auth(e, &admin, &manager, &Symbol::new(e, "manager"));␊ + access_control::grant_role_no_auth(e, &pauser, &Symbol::new(e, "pauser"), &admin);␊ + access_control::grant_role_no_auth(e, &minter, &Symbol::new(e, "minter"), &admin);␊ + access_control::grant_role_no_auth(e, &manager, &Symbol::new(e, "manager"), &admin);␊ }␊ ␊ #[only_role(caller, "minter")]␊ @@ -1008,13 +1011,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = AllowList;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -1045,7 +1047,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -1062,6 +1064,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl AccessControl for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -1078,10 +1083,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl AccessControl for MyStablecoin {}␊ ` ## stablecoin full - roles, blocklist @@ -1089,13 +1090,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String, Symbol};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::access_control::{self as access_control, AccessControl};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_role, when_not_paused};␊ + use stellar_macros::{only_role, when_not_paused};␊ use stellar_tokens::fungible::{␊ Base, blocklist::{BlockList, FungibleBlockList}, burnable::FungibleBurnable, FungibleToken␊ };␊ @@ -1113,12 +1116,12 @@ Generated by [AVA](https://avajs.dev). minter: Address,␊ manager: Address,␊ ) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 20000000000);␊ access_control::set_admin(e, &admin);␊ - access_control::grant_role_no_auth(e, &admin, &pauser, &Symbol::new(e, "pauser"));␊ - access_control::grant_role_no_auth(e, &admin, &minter, &Symbol::new(e, "minter"));␊ - access_control::grant_role_no_auth(e, &admin, &manager, &Symbol::new(e, "manager"));␊ + access_control::grant_role_no_auth(e, &pauser, &Symbol::new(e, "pauser"), &admin);␊ + access_control::grant_role_no_auth(e, &minter, &Symbol::new(e, "minter"), &admin);␊ + access_control::grant_role_no_auth(e, &manager, &Symbol::new(e, "manager"), &admin);␊ }␊ ␊ #[only_role(caller, "minter")]␊ @@ -1128,13 +1131,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyStablecoin {␊ type ContractType = BlockList;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -1165,7 +1167,7 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyStablecoin {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -1182,6 +1184,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl AccessControl for MyStablecoin {}␊ + ␊ #[contractimpl]␊ impl Pausable for MyStablecoin {␊ fn paused(e: &Env) -> bool {␊ @@ -1198,10 +1203,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl AccessControl for MyStablecoin {}␊ ` ## stablecoin full - complex name @@ -1209,13 +1210,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_access::ownable::{self as ownable, Ownable};␊ use stellar_contract_utils::pausable::{self as pausable, Pausable};␊ - use stellar_macros::{default_impl, only_owner, when_not_paused};␊ + use stellar_macros::{only_owner, when_not_paused};␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -1224,8 +1227,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl CustomToken {␊ pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "Custom $ Token"), String::from_str(e, "MST"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "Custom $ Token"), String::from_str(e, "MST"));␊ + Base::mint(e, &recipient, 20000000000);␊ ownable::set_owner(e, &owner);␊ }␊ ␊ @@ -1236,13 +1239,12 @@ Generated by [AVA](https://avajs.dev). }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for CustomToken {␊ type ContractType = Base;␊ ␊ #[when_not_paused]␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -1256,7 +1258,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for CustomToken {␊ #[when_not_paused]␊ fn burn(e: &Env, from: Address, amount: i128) {␊ @@ -1273,6 +1275,9 @@ Generated by [AVA](https://avajs.dev). // Utils␊ //␊ ␊ + #[contractimpl(contracttrait)]␊ + impl Ownable for CustomToken {}␊ + ␊ #[contractimpl]␊ impl Pausable for CustomToken {␊ fn paused(e: &Env) -> bool {␊ @@ -1289,10 +1294,6 @@ Generated by [AVA](https://avajs.dev). pausable::unpause(e);␊ }␊ }␊ - ␊ - #[default_impl]␊ - #[contractimpl]␊ - impl Ownable for CustomToken {}␊ ` ## stablecoin explicit trait implementations @@ -1300,10 +1301,12 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ #![no_std]␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, FungibleToken};␊ ␊ #[contract]␊ @@ -1312,7 +1315,7 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyStablecoin {␊ pub fn __constructor(e: &Env) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ + Base::set_metadata(e, 7, String::from_str(e, "MyStablecoin"), String::from_str(e, "MST"));␊ }␊ }␊ ␊ @@ -1332,7 +1335,7 @@ Generated by [AVA](https://avajs.dev). Self::ContractType::allowance(e, &owner, &spender)␊ }␊ ␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ diff --git a/packages/core/stellar/src/stablecoin.test.ts.snap b/packages/core/stellar/src/stablecoin.test.ts.snap index 1b347ebdf..d196cdb83 100644 Binary files a/packages/core/stellar/src/stablecoin.test.ts.snap and b/packages/core/stellar/src/stablecoin.test.ts.snap differ diff --git a/packages/core/stellar/src/utils/version.ts b/packages/core/stellar/src/utils/version.ts index 20d840cec..9fe7720f4 100644 --- a/packages/core/stellar/src/utils/version.ts +++ b/packages/core/stellar/src/utils/version.ts @@ -1,15 +1,15 @@ /** * The actual latest version to use in links. */ -export const contractsVersion = '0.4.1'; +export const contractsVersion = '0.6.0'; export const contractsVersionTag = `v${contractsVersion}`; /** * Semantic version string representing of the minimum compatible version of Contracts to display in output. */ -export const compatibleContractsSemver = '^0.4.1'; +export const compatibleContractsSemver = '^0.6.0'; /** * The Soroban version for which compilation and testing have passing tests */ -export const compatibleSorobanVersion = '22.0.8'; +export const compatibleSorobanVersion = '23.4.0'; diff --git a/packages/core/stellar/src/zip-rust.compile.test.ts.md b/packages/core/stellar/src/zip-rust.compile.test.ts.md index 2a4007672..aa28730a1 100644 --- a/packages/core/stellar/src/zip-rust.compile.test.ts.md +++ b/packages/core/stellar/src/zip-rust.compile.test.ts.md @@ -10,11 +10,12 @@ Generated by [AVA](https://avajs.dev). [ `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ ␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ - use stellar_macros::default_impl;␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -23,13 +24,12 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, recipient: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 20000000000);␊ }␊ }␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleToken for MyToken {␊ type ContractType = Base;␊ ␊ @@ -39,8 +39,7 @@ Generated by [AVA](https://avajs.dev). // Extensions␊ //␊ ␊ - #[default_impl]␊ - #[contractimpl]␊ + #[contractimpl(contracttrait)]␊ impl FungibleBurnable for MyToken {}␊ `, `#![cfg(test)]␊ @@ -104,11 +103,11 @@ Generated by [AVA](https://avajs.dev). version = "0.0.1"␊ ␊ [workspace.dependencies]␊ - soroban-sdk = "22.0.8"␊ - stellar-tokens = "=0.4.1"␊ - stellar-access = "=0.4.1"␊ - stellar-contract-utils = "=0.4.1"␊ - stellar-macros = "=0.4.1"␊ + soroban-sdk = "23.4.0"␊ + stellar-tokens = "=0.6.0"␊ + stellar-access = "=0.6.0"␊ + stellar-contract-utils = "=0.6.0"␊ + stellar-macros = "=0.6.0"␊ ␊ ␊ [profile.release]␊ @@ -146,10 +145,12 @@ Generated by [AVA](https://avajs.dev). [ `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊ + // Compatible with OpenZeppelin Stellar Soroban Contracts ^0.6.0␊ ␊ ␊ - use soroban_sdk::{Address, contract, contractimpl, Env, String};␊ + use soroban_sdk::{␊ + Address, contract, contractimpl, Env, MuxedAddress, String, Symbol, Vec␊ + };␊ use stellar_tokens::fungible::{Base, burnable::FungibleBurnable, FungibleToken};␊ ␊ #[contract]␊ @@ -158,8 +159,8 @@ Generated by [AVA](https://avajs.dev). #[contractimpl]␊ impl MyToken {␊ pub fn __constructor(e: &Env, recipient: Address) {␊ - Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ - Base::mint(e, &recipient, 2000000000000000000000);␊ + Base::set_metadata(e, 7, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊ + Base::mint(e, &recipient, 20000000000);␊ }␊ }␊ ␊ @@ -179,7 +180,7 @@ Generated by [AVA](https://avajs.dev). Self::ContractType::allowance(e, &owner, &spender)␊ }␊ ␊ - fn transfer(e: &Env, from: Address, to: Address, amount: i128) {␊ + fn transfer(e: &Env, from: Address, to: MuxedAddress, amount: i128) {␊ Self::ContractType::transfer(e, &from, &to, amount);␊ }␊ ␊ @@ -280,11 +281,11 @@ Generated by [AVA](https://avajs.dev). version = "0.0.1"␊ ␊ [workspace.dependencies]␊ - soroban-sdk = "22.0.8"␊ - stellar-tokens = "=0.4.1"␊ - stellar-access = "=0.4.1"␊ - stellar-contract-utils = "=0.4.1"␊ - stellar-macros = "=0.4.1"␊ + soroban-sdk = "23.4.0"␊ + stellar-tokens = "=0.6.0"␊ + stellar-access = "=0.6.0"␊ + stellar-contract-utils = "=0.6.0"␊ + stellar-macros = "=0.6.0"␊ ␊ ␊ [profile.release]␊ diff --git a/packages/core/stellar/src/zip-rust.compile.test.ts.snap b/packages/core/stellar/src/zip-rust.compile.test.ts.snap index 871475099..ab029b4cf 100644 Binary files a/packages/core/stellar/src/zip-rust.compile.test.ts.snap and b/packages/core/stellar/src/zip-rust.compile.test.ts.snap differ diff --git a/packages/ui/src/stellar/TraitImplementationSection.svelte b/packages/ui/src/stellar/TraitImplementationSection.svelte index fa9cf86fc..87f526200 100644 --- a/packages/ui/src/stellar/TraitImplementationSection.svelte +++ b/packages/ui/src/stellar/TraitImplementationSection.svelte @@ -18,8 +18,8 @@

Trait Implementations - Whether the contract should use explicit trait implementations instead of the #[default_impl] macro to - auto-generate trait method bodies. + Whether the contract functions should be explicitly implemented or be auto-generated with the defaults provided by + the library.

@@ -27,7 +27,8 @@ Default Keep the #[default_impl] attribute so unused trait functions rely on the macro.The #[contractimpl(contracttrait)] attribute generates the contract functions with the defaults provided + in the trait. You can re-implement some of the functions with custom logic if needed. @@ -35,7 +36,7 @@ Explicit Generate every trait function body explicitly and omit the #[default_impl] attribute. Easier to customize.Include every trait function body explicitly. Useful when all of them need to be customized.