-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Playing with Raffles contract and adding some functions and transacti…
…ons to test it
- Loading branch information
Felipe Ribeiro
authored and
Felipe Ribeiro
committed
Dec 15, 2023
1 parent
0e2ed0a
commit beb9012
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import "Raffles" | ||
|
||
pub fun main(addr: Address, raffleId: UInt64): [Address] { | ||
let manager = getAccount(addr).getCapability<&Raffles.Manager{Raffles.ManagerPublic}>(Raffles.ManagerPublicPath).borrow() | ||
?? panic("unable to borrow manager") | ||
return manager.getRaffleAddresses(id: raffleId) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import "Raffles" | ||
|
||
pub fun main(addr: Address): [UInt64] { | ||
let manager = getAccount(addr).getCapability<&Raffles.Manager{Raffles.ManagerPublic}>(Raffles.ManagerPublicPath).borrow() | ||
?? panic("unable to borrow manager") | ||
return manager.getIDs() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import "Raffles" | ||
|
||
transaction(raffleId: UInt64, addressToAdd: Address) { | ||
prepare(acct: AuthAccount) { | ||
let manager = acct.borrow<&Raffles.Manager>(from: Raffles.ManagerStoragePath) | ||
?? panic("Could not borrow a reference to the Manager") | ||
|
||
manager.addAddressToRaffle(id: raffleId, address: addressToAdd) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import "Raffles" | ||
import "MetadataViews" | ||
|
||
transaction(raffleStart: UInt64?, raffleEnd: UInt64?, raffleTitle: String, raffleDescription: String, raffleImageUrl: String) { | ||
prepare(acct: AuthAccount) { | ||
let manager = acct.borrow<&Raffles.Manager>(from: Raffles.ManagerStoragePath) | ||
?? panic("Could not borrow a reference to the Manager") | ||
|
||
let addressRaffleSource <- manager.createAddressRaffleSource() | ||
|
||
let details = Raffles.Details( | ||
start: raffleStart, | ||
end: raffleEnd!, | ||
display: MetadataViews.Display( | ||
title: raffleTitle, | ||
description: raffleDescription, | ||
media: MetadataViews.HTTPFile( | ||
url: raffleImageUrl | ||
) | ||
) | ||
) | ||
|
||
manager.createRaffle(source: <- addressRaffleSource, details: details) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import "Raffles" | ||
|
||
transaction(raffleId: UInt64) { | ||
prepare(acct: AuthAccount) { | ||
let manager = acct.borrow<&Raffles.Manager>(from: Raffles.ManagerStoragePath) | ||
?? panic("Could not borrow a reference to the Manager") | ||
|
||
manager.draw(id: raffleId) | ||
} | ||
} |