Skip to content

Commit 1b5551e

Browse files
authored
Stellar: fix default_impl and ContractOverrides (#566)
1 parent 1dc33d9 commit 1b5551e

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

.changeset/pink-planes-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openzeppelin/wizard-stellar': patch
3+
---
4+
5+
Fix missing `ContractOverrides` import and rename `defaultimpl` to `default_impl`.

packages/core/stellar/src/non-fungible.test.ts.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,9 @@ Generated by [AVA](https://avajs.dev).
527527
#![no_std]␊
528528
529529
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
530+
use stellar_default_impl_macro::default_impl;␊
530531
use stellar_non_fungible::{␊
531-
Base, enumerable::{NonFungibleEnumerable, Enumerable}, NonFungibleToken␊
532+
Base, ContractOverrides, enumerable::{NonFungibleEnumerable, Enumerable}, NonFungibleToken␊
532533
};␊
533534
534535
#[contract]␊
@@ -600,7 +601,7 @@ Generated by [AVA](https://avajs.dev).
600601
// Extensions␊
601602
//␊
602603
603-
#[defaultimpl]␊
604+
#[default_impl]␊
604605
#[contractimpl]␊
605606
impl NonFungibleEnumerable for MyToken {}␊
606607
`
@@ -1293,9 +1294,10 @@ Generated by [AVA](https://avajs.dev).
12931294
Address, contract, contracterror, contractimpl, Env, panic_with_error, String, Symbol,␊
12941295
symbol_short␊
12951296
};␊
1297+
use stellar_default_impl_macro::default_impl;␊
12961298
use stellar_non_fungible::{␊
1297-
Base, burnable::NonFungibleBurnable, enumerable::{NonFungibleEnumerable, Enumerable},␊
1298-
NonFungibleToken␊
1299+
Base, burnable::NonFungibleBurnable, ContractOverrides,␊
1300+
enumerable::{NonFungibleEnumerable, Enumerable}, NonFungibleToken␊
12991301
};␊
13001302
use stellar_pausable::{self as pausable, Pausable};␊
13011303
use stellar_pausable_macros::when_not_paused;␊
@@ -1393,8 +1395,6 @@ Generated by [AVA](https://avajs.dev).
13931395
13941396
#[contractimpl]␊
13951397
impl NonFungibleBurnable for MyToken {␊
1396-
type ContractType = Enumerable;␊
1397-
13981398
#[when_not_paused]␊
13991399
fn burn(e: &Env, from: Address, token_id: u32) {␊
14001400
Self::ContractType::burn(e, &from, token_id);␊
@@ -1406,7 +1406,7 @@ Generated by [AVA](https://avajs.dev).
14061406
}␊
14071407
}␊
14081408
1409-
#[defaultimpl]␊
1409+
#[default_impl]␊
14101410
#[contractimpl]␊
14111411
impl NonFungibleEnumerable for MyToken {}␊
14121412
Binary file not shown.

packages/core/stellar/src/non-fungible.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function buildNonFungible(opts: NonFungibleOptions): Contract {
9898
}
9999

100100
if (allOpts.enumerable) {
101-
addEnumerable(c, allOpts.burnable);
101+
addEnumerable(c);
102102
}
103103

104104
if (allOpts.consecutive) {
@@ -179,24 +179,21 @@ function addBurnable(c: ContractBuilder, pausable: boolean) {
179179
}
180180
}
181181

182-
function addEnumerable(c: ContractBuilder, burnable: boolean) {
182+
function addEnumerable(c: ContractBuilder) {
183183
c.addUseClause('stellar_non_fungible', 'enumerable::{NonFungibleEnumerable, Enumerable}');
184-
//c.addUseClause('stellar_default_impl_macro', 'default_impl');
184+
c.addUseClause('stellar_default_impl_macro', 'default_impl');
185+
c.addUseClause('stellar_non_fungible', 'ContractOverrides');
185186

186187
const nonFungibleEnumerableTrait = {
187188
traitName: 'NonFungibleEnumerable',
188189
structName: c.name,
189-
tags: ['defaultimpl', 'contractimpl'],
190+
tags: ['default_impl', 'contractimpl'],
190191
section: 'Extensions',
191192
};
192193
c.addTraitImplBlock(nonFungibleEnumerableTrait);
193194

194195
c.overrideAssocType('NonFungibleToken', 'type ContractType = Enumerable;');
195196

196-
if (burnable) {
197-
c.overrideAssocType('NonFungibleBurnable', 'type ContractType = Enumerable;');
198-
}
199-
200197
// Below is not required due to `defaultimpl` macro. If we require to customize the functions,
201198
// then we should:
202199
// 1. get rid of the `defaultimpl` macro form `tags` above,

0 commit comments

Comments
 (0)