Skip to content

Commit

Permalink
storage path dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
saadtroon committed Feb 3, 2022
1 parent 25d8f9d commit 4bc2c2e
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 133 deletions.
2 changes: 1 addition & 1 deletion flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"emulator-account": [
"FungibleToken",
"FUSD",
"Controller",
"Controller",
"SocialToken"
],
"emulator-first": [],
Expand Down
7 changes: 4 additions & 3 deletions scripts/get_social_details.cdc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import Controller from "../contracts/Controller.cdc"
pub fun main(): Controller.TokenStructure? {
return Controller.allSocialTokens["S_0x120e725050340cab"]
import Controller from 0xf8d6e0586b0a20c7

pub fun main(name: String): Controller.TokenStructure? {
return Controller.getTokenDetails(name)
}
78 changes: 0 additions & 78 deletions tasks/burn_with_collateral/main.go

This file was deleted.

4 changes: 3 additions & 1 deletion tasks/get_burn_quote/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ func main() {
// - when referencing accounts in the "storyline" below note that the default option is to prepened the network to the account name, This is done so that it is easy to run a storyline against emulator, tesnet and mainnet. This can be disabled with the `DoNotPrependNetworkToAccountNames` method on the g object below.

flow := gwtf.NewGoWithTheFlowInMemoryEmulator()
// Register Token for a new account
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

result := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("2.0").RunFailOnError()
result := flow.ScriptFromFile("get_social_burn_quote").UFix64Argument("2.0").RunFailOnError()
log.Printf("Script returned %s", result)

}
6 changes: 4 additions & 2 deletions tasks/get_mint_quote/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ func main() {
// - when referencing accounts in the "storyline" below note that the default option is to prepened the network to the account name, This is done so that it is easy to run a storyline against emulator, tesnet and mainnet. This can be disabled with the `DoNotPrependNetworkToAccountNames` method on the g object below.

flow := gwtf.NewGoWithTheFlowInMemoryEmulator()
// Register Token for a new account
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

result := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("2.0").RunFailOnError()
log.Printf("Script returned %s", result)
result := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("2.0").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf("Script returned Social Mint quote %s", result)

}
7 changes: 5 additions & 2 deletions tasks/get_social_details/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ func main() {

flow := gwtf.NewGoWithTheFlowInMemoryEmulator()

result := flow.ScriptFromFile("get_social_details").RunFailOnError()
log.Printf("Script returned %s", result)
//Register Token for a new account
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

result := flow.ScriptFromFile("get_social_details").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf("Script returned Social Details %s", result)

}
16 changes: 12 additions & 4 deletions tasks/mint_burn_instant/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,25 @@ func main() {
//Log balance
fusdFirstAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("first").RunFailOnError()
log.Printf("FUSD balance of account 'first account' %s", fusdFirstAccountBalance)

//-------------------------------------------------//
//--------- Register Account -----------//
//-------------------------------------------------//

//Register Token for a new account
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

//-------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN -----------//
//-------------------------------------------------//

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
flow.TransactionFromFile("setup_admin_account").SignProposeAndPayAs("account").RunPrintEventsFull()

flow.TransactionFromFile("add_admin_account").SignProposeAndPayAs("account").AccountArgument("account").RunPrintEventsFull()

//--------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN ------------//
//--------------------------------------------------//

//Setup SocialToken Vaults for both accounts
flow.TransactionFromFile("setup_social_vault").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunPrintEventsFull()
Expand Down
47 changes: 31 additions & 16 deletions tasks/mint_with_collateral/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func main() {

//This method starts an in memory flow emulator
//This method starts an in memory flow emulator
// - it then looks at all the contracts in the deployment block for emulator and deploys them
// - then it looks at all the accounts that does not have contracts in them and create those accounts. These can be used as stakeholders in your "storyline" below.
// - when referencing accounts in the "storyline" below note that the default option is to prepened the network to the account name, This is done so that it is easy to run a storyline against emulator, tesnet and mainnet. This can be disabled with the `DoNotPrependNetworkToAccountNames` method on the g object below.
Expand All @@ -18,48 +18,63 @@ func main() {
//FUSD//

//Setup FUSD Vaults for all accounts
log.Printf(" ------")
flow.TransactionFromFile("setup_fusd_vault").SignProposeAndPayAs("first").RunPrintEventsFull()
log.Printf(" ---")

flow.TransactionFromFile("setup_fusd_vault").SignProposeAndPayAs("account").RunPrintEventsFull()
log.Printf(" ---")

flow.TransactionFromFile("setup_fusd_vault").SignProposeAndPayAs("second").RunPrintEventsFull() // Artist Vault

//First Account sets up FUSD Minter
flow.TransactionFromFile("setup_fusd_minter").SignProposeAndPayAs("first").RunPrintEventsFull()

//Admin Account deposits minter into first account
flow.TransactionFromFile("deposit_fusd_minter").SignProposeAndPayAs("account").AccountArgument("first").RunPrintEventsFull()
flow.TransactionFromFile("set_minter_proxy").SignProposeAndPayAs("account").AccountArgument("first").RunPrintEventsFull()

// First Account Mints and deposits in one transaction
flow.TransactionFromFile("mint_fusd").SignProposeAndPayAs("first").UFix64Argument("100.00").AccountArgument("first").RunPrintEventsFull()
flow.TransactionFromFile("mint_fusd").SignProposeAndPayAs("first").UFix64Argument("10000000.00").AccountArgument("second").RunPrintEventsFull()

//Log balance
fusdFirstAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("first").RunFailOnError()
log.Printf("FUSD balance of account 'first account' %s", fusdFirstAccountBalance)

//-------------------------------------------------//
//--------- Register Account -----------//
//-------------------------------------------------//

//Register Token for a new account
flow.TransactionFromFile("controller/registerToken").SignProposeAndPayAs("account").UFix64Argument("100.00").AccountArgument("first").StringArgument("TestSymbol").RunPrintEventsFull()
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

//-------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN -----------//
//-------------------------------------------------//

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
flow.TransactionFromFile("setup_admin_account").SignProposeAndPayAs("account").RunPrintEventsFull()

flow.TransactionFromFile("add_admin_account").SignProposeAndPayAs("account").AccountArgument("account").RunPrintEventsFull()

//--------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN ------------//
//--------------------------------------------------//

//Setup SocialToken Vaults for both accounts
flow.TransactionFromFile("social_token/setup_social_vault").SignProposeAndPayAs("first").RunPrintEventsFull()
flow.TransactionFromFile("setup_social_vault").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunPrintEventsFull()
//flow.TransactionFromFile("social_token/setup_social_vault").SignProposeAndPayAs("account").RunPrintEventsFull()

//Admin Account deposits minter into first account
// flow.TransactionFromFile("social_token/deposit_social_minter").SignProposeAndPayAs("account").AccountArgument("first").RunPrintEventsFull()
mintQuote := flow.ScriptFromFile("getTokenDetails").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ Social Token Details ----- %s", mintQuote)


mintQuote := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("100.00").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()

// mint social Tokens
flow.TransactionFromFile("social_token/mint_social_token").SignProposeAndPayAs("first").UFix64Argument("100.00").UFix64Argument("100.00").RunPrintEventsFull()
flow.TransactionFromFile("mint_social_token").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").UFix64Argument("100.00").UFix64Argument(mintQuote.String()).RunPrintEventsFull()

log.Printf(" ------ mintQuote is ----- %s", mintQuote)


// Get the balance of all accounts
ArtistAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("second").RunFailOnError()
log.Printf(" ------ Artist Account Balance got 3 percent ----- %s", ArtistAccountBalance)
ArtistAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("first").RunFailOnError()
log.Printf(" ------ Artist Account Balance got 15 percent of mint quote ----- %s", ArtistAccountBalance)

}
66 changes: 50 additions & 16 deletions tasks/mint_with_fee_distribution/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (

"log"

"github.com/bjartek/go-with-the-flow/v2/gwtf"
Expand Down Expand Up @@ -36,36 +37,69 @@ func main() {
// First Account Mints and deposits in one transaction
flow.TransactionFromFile("mint_fusd").SignProposeAndPayAs("first").UFix64Argument("10000000.00").AccountArgument("second").RunPrintEventsFull()



//Log balance
fusdFirstAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("first").RunFailOnError()
log.Printf("FUSD balance of account 'first account' %s", fusdFirstAccountBalance)

//-------------------------------------------------//
//--------- Register Account -----------//
//-------------------------------------------------//

//Register Token for a new account
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("S").UFix64Argument("1000.00").AccountArgument("first").RunPrintEventsFull()
flow.TransactionFromFile("registerToken").SignProposeAndPayAs("account").StringArgument("TestSymbol").UFix64Argument("10000000.00").AccountArgument("first").RunPrintEventsFull()

//-------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN -----------//
//-------------------------------------------------//

//--------------------------------------------------//
//-- SETUP Admin and Add Capability of Controller --//
//--------------------------------------------------//
flow.TransactionFromFile("setup_admin_account").SignProposeAndPayAs("account").RunPrintEventsFull()

flow.TransactionFromFile("add_admin_account").SignProposeAndPayAs("account").AccountArgument("account").RunPrintEventsFull()

//--------------------------------------------------//
//--------- SETUP AND MINT SOCIAL TOKEN ------------//
//--------------------------------------------------//

//Setup SocialToken Vaults for both accounts
flow.TransactionFromFile("setup_social_vault").SignProposeAndPayAs("second").RunPrintEventsFull()
flow.TransactionFromFile("setup_social_vault").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunPrintEventsFull()
//flow.TransactionFromFile("social_token/setup_social_vault").SignProposeAndPayAs("account").RunPrintEventsFull()

//Admin Account deposits minter into first account
// flow.TransactionFromFile("social_token/deposit_social_minter").SignProposeAndPayAs("account").AccountArgument("first").RunPrintEventsFull()

mintQuote := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("10.00").StringArgument("S_0x1cf0e2f2f715450").RunFailOnError()
//Log balance
fusdFirstAccountBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("second").RunFailOnError()

log.Printf("FUSD balance of user account' %s", fusdFirstAccountBalance)
mintQuote := flow.ScriptFromFile("get_social_mint_quote").UFix64Argument("10000000.00").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()

// mint social Tokens
flow.TransactionFromFile("mint_social_token").SignProposeAndPayAs("second").StringArgument("S_0x1cf0e2f2f715450").UFix64Argument("100.00").UFix64Argument(mintQuote.String()).RunPrintEventsFull()
flow.TransactionFromFile("mint_social_token").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").UFix64Argument("10000000.00").UFix64Argument(mintQuote.String()).RunPrintEventsFull()

log.Printf(" ------ Social Mint Quote ----- %s", mintQuote)
//Admin Account deposits minter into first account
// flow.TransactionFromFile("social_token/deposit_social_minter").SignProposeAndPayAs("account").AccountArgument("first").RunPrintEventsFull()
TokenDetails := flow.ScriptFromFile("getTokenDetails").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ Social Token Details ----- %s", TokenDetails)

// Get the balance of all accounts
ArtistAccountBalance := flow.ScriptFromFile("get_issued_supply").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ get Issued Supply ----- %s", ArtistAccountBalance)

BurnPrice := flow.ScriptFromFile("get_social_burn_quote").UFix64Argument("10000000.00").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ User Burn Price ----- %s", BurnPrice)

UserSocialBalance := flow.ScriptFromFile("get_social_balance").AccountArgument("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ User Social Token Balance ----- %s", UserSocialBalance)
// burn social Tokens
flow.TransactionFromFile("burn_social_token").SignProposeAndPayAs("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").UFix64Argument("10000000.00000000").RunPrintEventsFull()
// Get the balance of all accounts
ArtistAccountBalanceFUSD := flow.ScriptFromFile("get_fusd_balance").AccountArgument("second").RunFailOnError()
log.Printf(" ------ User FUSD Balance after burning ----- %s", ArtistAccountBalanceFUSD)

ArtistAccountBalance = flow.ScriptFromFile("get_social_balance").AccountArgument("second").StringArgument("TestSymbol_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ User Social Balance after burning ----- %s", ArtistAccountBalance)

//Log balance
fusdFirstAccountBalance = flow.ScriptFromFile("get_fusd_balance").AccountArgument("first").RunFailOnError()
log.Printf("FUSD balance of account 'artist account' %s", fusdFirstAccountBalance)

UserSocialBalance := flow.ScriptFromFile("get_social_balance").AccountArgument("second").StringArgument("S_0x1cf0e2f2f715450").RunFailOnError()
log.Printf(" ------ User Social Token Balance of S ----- %s", UserSocialBalance)
AdminBalance := flow.ScriptFromFile("get_fusd_balance").AccountArgument("account").RunFailOnError()
log.Printf("Admin balance of account %s", AdminBalance)

}
2 changes: 1 addition & 1 deletion test/js/index-test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ describe("Scripts", () => {
}
})
test("test script for getting the social vault balance of user", async () => {
const name = "get_social_balance_7"
const name = "get_social_balance"

const FungibleToken = "0xee82856bf20e2aa6"
const SocialToken = await getContractAddress("SocialToken")
Expand Down
Loading

0 comments on commit 4bc2c2e

Please sign in to comment.