Skip to content

Commit 0412ab6

Browse files
committed
rework init for ExampleToken
1 parent 454b0f5 commit 0412ab6

File tree

4 files changed

+117
-95
lines changed

4 files changed

+117
-95
lines changed

contracts/ExampleToken.cdc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,22 @@ access(all) contract ExampleToken: FungibleToken {
197197
}
198198

199199
init() {
200-
self.totalSupply = 1000.0
200+
self.totalSupply = 0.0
201201

202202
self.VaultStoragePath = /storage/exampleTokenVault
203203
self.VaultPublicPath = /public/exampleTokenVault
204204
self.ReceiverPublicPath = /public/exampleTokenReceiver
205205
self.AdminStoragePath = /storage/exampleTokenAdmin
206206

207+
let admin <- create Minter()
208+
207209
// Create the Vault with the total supply of tokens and save it in storage
208210
//
209-
let vault <- create Vault(balance: self.totalSupply)
210-
emit TokensMinted(amount: vault.balance, type: vault.getType().identifier)
211+
let vault <- admin.mintTokens(amount: 1000.0)
212+
213+
self.account.storage.save(<-vault, to: self.VaultStoragePath)
214+
215+
self.account.storage.save(<-admin, to: self.AdminStoragePath)
211216

212217
// Create a public capability to the stored Vault that exposes
213218
// the `deposit` method and getAcceptedTypes method through the `Receiver` interface
@@ -217,10 +222,5 @@ access(all) contract ExampleToken: FungibleToken {
217222
self.account.capabilities.publish(exampleTokenCap, at: self.VaultPublicPath)
218223
let receiverCap = self.account.capabilities.storage.issue<&ExampleToken.Vault>(self.VaultStoragePath)
219224
self.account.capabilities.publish(receiverCap, at: self.ReceiverPublicPath)
220-
221-
self.account.storage.save(<-vault, to: /storage/exampleTokenVault)
222-
223-
let admin <- create Minter()
224-
self.account.storage.save(<-admin, to: self.AdminStoragePath)
225225
}
226226
}

0 commit comments

Comments
 (0)