@openzeppelin/wizard-stellar 0.6.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts.map +1 -1
- package/dist/account.js +18 -4
- package/dist/account.js.map +1 -1
- package/dist/add-votes.d.ts +3 -0
- package/dist/add-votes.d.ts.map +1 -0
- package/dist/add-votes.js +53 -0
- package/dist/add-votes.js.map +1 -0
- package/dist/fungible.d.ts +13 -2
- package/dist/fungible.d.ts.map +1 -1
- package/dist/fungible.js +146 -76
- package/dist/fungible.js.map +1 -1
- package/dist/generate/fungible.d.ts.map +1 -1
- package/dist/generate/fungible.js +2 -0
- package/dist/generate/fungible.js.map +1 -1
- package/dist/generate/non-fungible.d.ts.map +1 -1
- package/dist/generate/non-fungible.js +2 -0
- package/dist/generate/non-fungible.js.map +1 -1
- package/dist/generate/stablecoin.d.ts.map +1 -1
- package/dist/generate/stablecoin.js +2 -0
- package/dist/generate/stablecoin.js.map +1 -1
- package/dist/governor.d.ts.map +1 -1
- package/dist/governor.js +9 -1
- package/dist/governor.js.map +1 -1
- package/dist/non-fungible.d.ts +2 -0
- package/dist/non-fungible.d.ts.map +1 -1
- package/dist/non-fungible.js +152 -126
- package/dist/non-fungible.js.map +1 -1
- package/dist/print.js +16 -1
- package/dist/print.js.map +1 -1
- package/dist/stablecoin.d.ts.map +1 -1
- package/dist/stablecoin.js +6 -31
- package/dist/stablecoin.js.map +1 -1
- package/dist/utils/compose.d.ts +6 -0
- package/dist/utils/compose.d.ts.map +1 -0
- package/dist/utils/compose.js +12 -0
- package/dist/utils/compose.js.map +1 -0
- package/dist/utils/version.d.ts +4 -4
- package/dist/utils/version.js +3 -3
- package/dist/vault.d.ts +1 -1
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +27 -7
- package/dist/vault.js.map +1 -1
- package/dist/zip-shared.d.ts.map +1 -1
- package/dist/zip-shared.js +4 -3
- package/dist/zip-shared.js.map +1 -1
- package/package.json +1 -1
- package/src/account.ts +18 -4
- package/src/add-votes.ts +53 -0
- package/src/fungible.ts +170 -85
- package/src/generate/fungible.ts +2 -0
- package/src/generate/non-fungible.ts +2 -0
- package/src/generate/stablecoin.ts +2 -0
- package/src/governor.ts +10 -1
- package/src/non-fungible.ts +182 -143
- package/src/print.ts +14 -1
- package/src/stablecoin.ts +9 -37
- package/src/utils/compose.ts +8 -0
- package/src/utils/version.ts +3 -3
- package/src/vault.ts +32 -7
- package/src/zip-shared.ts +4 -3
package/src/vault.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { setInfo } from './set-info';
|
|
|
10
10
|
import { contractDefaults as commonDefaults } from './common-options';
|
|
11
11
|
import { printContract } from './print';
|
|
12
12
|
import { toByteArray, toUint } from './utils/convert-strings';
|
|
13
|
+
import { printComposedContractType } from './utils/compose';
|
|
13
14
|
import { OptionsError } from './error';
|
|
14
15
|
import { pickKeys } from '@openzeppelin/wizard-common';
|
|
15
16
|
|
|
@@ -119,7 +120,16 @@ function addBase(
|
|
|
119
120
|
|
|
120
121
|
// Set token functions
|
|
121
122
|
c.addUseClause('stellar_tokens::fungible', 'Base');
|
|
123
|
+
c.addUseClause('stellar_tokens::fungible', 'Compose');
|
|
122
124
|
c.addUseClause('stellar_tokens::fungible', 'FungibleToken');
|
|
125
|
+
// `Vault` provides the total supply only through the `TotalSupplyOverrides` trait, which the
|
|
126
|
+
// explicitly implemented `total_supply` needs in scope.
|
|
127
|
+
c.addUseClause(
|
|
128
|
+
'stellar_tokens::fungible',
|
|
129
|
+
explicitImplementations
|
|
130
|
+
? 'total_supply::{FungibleTotalSupply, TotalSupply, TotalSupplyOverrides}'
|
|
131
|
+
: 'total_supply::{FungibleTotalSupply, TotalSupply}',
|
|
132
|
+
);
|
|
123
133
|
c.addUseClause('stellar_tokens::vault', 'FungibleVault');
|
|
124
134
|
c.addUseClause('stellar_tokens::vault', 'Vault');
|
|
125
135
|
// The base token functions we emit delegate to `Self::ContractType::...`,
|
|
@@ -138,7 +148,8 @@ function addBase(
|
|
|
138
148
|
traitName: 'FungibleToken',
|
|
139
149
|
structName: c.name,
|
|
140
150
|
tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'],
|
|
141
|
-
|
|
151
|
+
// The vault tracks the share supply, which the library requires to be stated with `TotalSupply`.
|
|
152
|
+
assocType: printComposedContractType(['Vault', 'TotalSupply']),
|
|
142
153
|
};
|
|
143
154
|
|
|
144
155
|
c.addTraitImplBlock(fungibleTokenTrait);
|
|
@@ -161,6 +172,19 @@ function addBase(
|
|
|
161
172
|
c.addFunctionTag(functions.transfer_from, 'when_not_paused', fungibleTokenTrait);
|
|
162
173
|
}
|
|
163
174
|
|
|
175
|
+
const fungibleTotalSupplyTrait = {
|
|
176
|
+
traitName: 'FungibleTotalSupply',
|
|
177
|
+
structName: c.name,
|
|
178
|
+
tags: explicitImplementations ? ['contractimpl'] : ['contractimpl(contracttrait)'],
|
|
179
|
+
section: 'Extensions',
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
if (explicitImplementations) {
|
|
183
|
+
c.addTraitFunction(fungibleTotalSupplyTrait, functions.total_supply);
|
|
184
|
+
} else {
|
|
185
|
+
c.addTraitImplBlock(fungibleTotalSupplyTrait);
|
|
186
|
+
}
|
|
187
|
+
|
|
164
188
|
const fungibleVaultTrait = {
|
|
165
189
|
traitName: 'FungibleVault',
|
|
166
190
|
structName: c.name,
|
|
@@ -177,11 +201,6 @@ function addBase(
|
|
|
177
201
|
|
|
178
202
|
export const functions = defineFunctions({
|
|
179
203
|
// FungibleToken Trait
|
|
180
|
-
total_supply: {
|
|
181
|
-
args: [getSelfArg()],
|
|
182
|
-
returns: 'i128',
|
|
183
|
-
code: ['Self::ContractType::total_supply(e)'],
|
|
184
|
-
},
|
|
185
204
|
balance: {
|
|
186
205
|
args: [getSelfArg(), { name: 'account', type: 'Address' }],
|
|
187
206
|
returns: 'i128',
|
|
@@ -239,6 +258,13 @@ export const functions = defineFunctions({
|
|
|
239
258
|
code: ['Self::ContractType::symbol(e)'],
|
|
240
259
|
},
|
|
241
260
|
|
|
261
|
+
// FungibleTotalSupply Trait
|
|
262
|
+
total_supply: {
|
|
263
|
+
args: [getSelfArg()],
|
|
264
|
+
returns: 'i128',
|
|
265
|
+
code: ['Self::ContractType::total_supply(e)'],
|
|
266
|
+
},
|
|
267
|
+
|
|
242
268
|
// FungibleVault Trait
|
|
243
269
|
query_asset: {
|
|
244
270
|
args: [getSelfArg()],
|
|
@@ -347,7 +373,6 @@ export const functions = defineFunctions({
|
|
|
347
373
|
});
|
|
348
374
|
|
|
349
375
|
const fungibleTokenTraitFunctions = pickKeys(functions, [
|
|
350
|
-
'total_supply',
|
|
351
376
|
'balance',
|
|
352
377
|
'allowance',
|
|
353
378
|
'transfer',
|
package/src/zip-shared.ts
CHANGED
|
@@ -57,7 +57,7 @@ extern crate std;
|
|
|
57
57
|
use soroban_sdk::{
|
|
58
58
|
contract, contractimpl, testutils::Address as _, Address, Env, MuxedAddress, String,
|
|
59
59
|
};
|
|
60
|
-
use stellar_tokens::fungible::{Base, FungibleToken};
|
|
60
|
+
use stellar_tokens::fungible::{Base, Compose, FungibleToken};
|
|
61
61
|
|
|
62
62
|
use crate::contract::{ ${c.name}, ${c.name}Client };
|
|
63
63
|
|
|
@@ -74,13 +74,13 @@ impl MockAssetContract {
|
|
|
74
74
|
String::from_str(e, "Mock Asset Token"),
|
|
75
75
|
String::from_str(e, "MAT"),
|
|
76
76
|
);
|
|
77
|
-
|
|
77
|
+
<Self as FungibleToken>::ContractType::mint(e, &admin, initial_supply);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
#[contractimpl(contracttrait)]
|
|
82
82
|
impl FungibleToken for MockAssetContract {
|
|
83
|
-
type ContractType = Base
|
|
83
|
+
type ContractType = Compose<(Base,)>;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
#[test]
|
|
@@ -95,6 +95,7 @@ fn initial_state() {
|
|
|
95
95
|
|
|
96
96
|
assert_eq!(client.query_asset(), asset_address);
|
|
97
97
|
assert_eq!(client.name(), String::from_str(&env, "${c.name}"));
|
|
98
|
+
assert_eq!(client.total_supply(), 0);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
// Add more tests bellow
|