Skip to content

Commit

Permalink
allow one admin to make another (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline authored Dec 20, 2023
1 parent ccd39a8 commit 1bb3721
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 6 deletions.
4 changes: 4 additions & 0 deletions contracts/FlowtyWrapped.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ pub contract FlowtyWrapped: NonFungibleToken, ViewResolver {
pub fun setCollectionExternalUrl(_ s: String) {
FlowtyWrapped.collectionExternalUrl = s
}

pub fun createAdmin(): @Admin {
return <- create Admin()
}
}

/// Function that resolves a metadata view for this contract.
Expand Down
2 changes: 1 addition & 1 deletion contracts/WrappedEditions.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub contract WrappedEditions {
)
case Type<MetadataViews.Medias>():
let htmlMedia = MetadataViews.Media(
file: MetadataViews.IPFSFile("", nil), mediaType: "text/html"
file: MetadataViews.IPFSFile(self.baseHtmlUrl, nil), mediaType: "text/html"
)
let imageMedia = MetadataViews.Media(
file: MetadataViews.HTTPFile(url: self.baseImageUrl.concat(nft.serial.toString())), mediaType: "image/jpeg"
Expand Down
12 changes: 8 additions & 4 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"source": "./contracts/FlowtyWrapped.cdc",
"aliases": {
"emulator": "0xf8d6e0586b0a20c7",
"testnet": "0x60c19518441ca1c4",
"testnet": "0xd1712bc9e162f9e3",
"testing": "0x0000000000000007"
}
},
"WrappedEditions": {
"source": "./contracts/WrappedEditions.cdc",
"aliases": {
"emulator": "0xf8d6e0586b0a20c7",
"testnet": "0x60c19518441ca1c4",
"testnet": "0xd1712bc9e162f9e3",
"testing": "0x0000000000000007"
}
},
Expand Down Expand Up @@ -99,13 +99,17 @@
"key": "bcdf616be1686d3542dfcee8be0079721828465c5fd9f19a8bb96fe62d585ad1"
},
"wrapped-testnet": {
"address": "0x60c19518441ca1c4",
"address": "0xd1712bc9e162f9e3",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/flowty-test/locations/global/keyRings/flow/cryptoKeys/wrapped/cryptoKeyVersions/1"
}
}
},
"testnet-minter": {
"address": "0x241d62cdfcf9656b",
"key": "e15cc2e96404ce4efa654fc237ccae3f8765c626cd3f3df0f244f167859b2612"
}
},
"deployments": {
"emulator": {
Expand Down
11 changes: 11 additions & 0 deletions transactions/claim_admin.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "FlowtyWrapped"

transaction(name: String, provider: Address) {
prepare(acct: AuthAccount) {
let providerAdmin = acct.inbox.claim<&FlowtyWrapped.Admin>(name, provider: provider)
?? panic("capabiltiy not found")

let admin <- providerAdmin.borrow()!.createAdmin()
acct.save(<-admin, to: FlowtyWrapped.AdminStoragePath)
}
}
1 change: 0 additions & 1 deletion transactions/mint_flowty_wrapped.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ transaction(address: Address, username: String, ticket: Int, totalNftsOwned: Int
//borrow a reference to the NFTMinter resource in storage
self.minter = acct.borrow<&FlowtyWrapped.Admin>(from: FlowtyWrapped.AdminStoragePath)
?? panic("Could not borrow a reference to the NFT minter")

}

execute {
Expand Down
14 changes: 14 additions & 0 deletions transactions/publish_admin.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "FlowtyWrapped"

transaction(receiver: Address) {
prepare(acct: AuthAccount) {
let identifier = "FlowtyWrapped_Admin_".concat(receiver.toString())
let p = PrivatePath(identifier: identifier)!

acct.unlink(p)
let cap = acct.link<&FlowtyWrapped.Admin>(p, target: FlowtyWrapped.AdminStoragePath)
?? panic("failed to link admin capability")

acct.inbox.publish(cap, name: "flowty-wrapped-minter", recipient: receiver)
}
}
1 change: 1 addition & 0 deletions transactions/register_edition.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "WrappedEditions"
import "FlowtyRaffles"
import "FlowtyRaffleSource"

// flow transactions send ./transactions/register_edition.cdc false 1703035065 1705195052 "https://storage.googleapis.com/flowty-wrapped-2023-testnet/" QmcvXz8zZ8hZwgH95zVQ8ZEJUZ92oR9MVjCFVYePyCuvxB -n testnet --signer wrapped-testnet
transaction(removeAfterReveal: Bool, start: UInt64, end: UInt64, baseImageUrl: String, baseHtmlUrl: String) {
prepare(acct: AuthAccount) {
let raffleManager = acct.borrow<&FlowtyRaffles.Manager>(from: FlowtyRaffles.ManagerStoragePath)!
Expand Down
25 changes: 25 additions & 0 deletions transactions/register_key.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Crypto

/*
[
ac915cf356a8da0adbd6fb7bed6e4d7c6b3a6a5a3afd933aadb09bddda246acc7700ebcac5aa113646e5c6b0409890ebafa14b9160cdde0b7f96fde2e1ab72d3: String,
1: UInt8,
3: UInt8,
1000.00000000: UFix64
]
*/

transaction(publicKey: String, signatureAlgorithm: UInt8, hashAlgorithm: UInt8, weight: UFix64) {
prepare(signer: AuthAccount) {
let key = PublicKey(
publicKey: publicKey.decodeHex(),
signatureAlgorithm: SignatureAlgorithm(rawValue: signatureAlgorithm)!
)

signer.keys.add(
publicKey: key,
hashAlgorithm: HashAlgorithm(rawValue: hashAlgorithm)!,
weight: weight
)
}
}

0 comments on commit 1bb3721

Please sign in to comment.