Skip to content

Commit 471f3b3

Browse files
authored
Update to latest Gold Star contracts & deploy mainnet (#1118)
1 parent 0b5d7c4 commit 471f3b3

File tree

10 files changed

+46
-36
lines changed

10 files changed

+46
-36
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ docs/.obsidian
4040
# flow
4141
imports
4242

43-
goldstar-testnet.pkey
43+
goldstar-testnet.pkey
44+
goldstar-mainnet.pkey

flow.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"testing": "0000000000000007"
1313
}
1414
},
15-
"ManualChallenge": {
16-
"source": "./src/cadence/contracts/ManualChallenge.cdc",
15+
"LearnFlowChallenge": {
16+
"source": "./src/cadence/contracts/LearnFlowChallenge.cdc",
1717
"aliases": {
1818
"testing": "0000000000000007"
1919
}
2020
},
21-
"NoopChallenge": {
22-
"source": "./src/cadence/contracts/NoopChallenge.cdc",
21+
"ManualChallenge": {
22+
"source": "./src/cadence/contracts/ManualChallenge.cdc",
2323
"aliases": {
2424
"testing": "0000000000000007"
2525
}
@@ -104,17 +104,27 @@
104104
"location": "emulator-account.pkey"
105105
}
106106
},
107+
"goldstar-mainnet": {
108+
"address": "e99f9883203ff565",
109+
"key": {
110+
"type": "file",
111+
"location": "goldstar-mainnet.pkey"
112+
}
113+
},
107114
"goldstar-testnet": {
108-
"address": "441ea660554acb42",
115+
"address": "032b0464e2e8fccc",
109116
"key": {
110117
"type": "file",
111118
"location": "goldstar-testnet.pkey"
112119
}
113120
}
114121
},
115122
"deployments": {
123+
"mainnet": {
124+
"goldstar-mainnet": ["GoldStar", "LearnFlowChallenge"]
125+
},
116126
"testnet": {
117-
"goldstar-testnet": ["GoldStar", "NoopChallenge"]
127+
"goldstar-testnet": ["GoldStar", "LearnFlowChallenge"]
118128
}
119129
}
120130
}

src/cadence/contracts/GoldStar.cdc

+8-11
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ contract GoldStar {
1010
access(all)
1111
let adminStoragePath: StoragePath
1212

13-
access(all)
14-
entitlement Owner
15-
1613
access(all)
1714
entitlement UpdateHandle
1815

@@ -94,7 +91,7 @@ contract GoldStar {
9491
access(all)
9592
var evmContracts: {String: Bool}
9693

97-
access(Owner | UpdateDeployedContracts)
94+
access(UpdateDeployedContracts)
9895
fun addCadenceContract(address: Address, name: String) {
9996
if let names = self.cadenceContracts[address] {
10097
names[name] = true
@@ -103,13 +100,13 @@ contract GoldStar {
103100
}
104101
}
105102

106-
access(Owner | UpdateDeployedContracts)
103+
access(UpdateDeployedContracts)
107104
fun addEvmContract(address: [UInt8; 20]) {
108105
var addressString = String.encodeHex(address.toVariableSized())
109106
self.evmContracts[addressString] = true
110107
}
111108

112-
access(Owner | UpdateDeployedContracts)
109+
access(UpdateDeployedContracts)
113110
fun removeCadenceContract(address: Address, name: String) {
114111
if let names = self.cadenceContracts[address] {
115112
names.remove(key: name)
@@ -119,7 +116,7 @@ contract GoldStar {
119116
}
120117
}
121118

122-
access(Owner | UpdateDeployedContracts)
119+
access(UpdateDeployedContracts)
123120
fun removeEvmContract(address: [UInt8; 20]) {
124121
var addressString = String.encodeHex(address.toVariableSized())
125122
self.evmContracts.remove(key: addressString)
@@ -136,12 +133,12 @@ contract GoldStar {
136133
access(all)
137134
var socials: {String: String}
138135

139-
access(Owner | UpdateSocials)
136+
access(UpdateSocials)
140137
fun set(name: String, handle: String) {
141138
self.socials[name] = handle
142139
}
143140

144-
access(Owner | UpdateSocials)
141+
access(UpdateSocials)
145142
fun remove(name: String) {
146143
self.socials.remove(key: name)
147144
}
@@ -156,14 +153,14 @@ contract GoldStar {
156153
access(all)
157154
var submissions: @{Type: {Submission}}
158155

159-
access(Owner | UpdateSubmissions)
156+
access(UpdateSubmissions)
160157
fun add(_ submission: @{Submission}, challengeType: Type): &{Submission} {
161158
self.submissions[challengeType] <-! submission
162159
let ref = &self.submissions[challengeType] as &{Submission}?
163160
return ref!
164161
}
165162

166-
access(Owner | UpdateSubmissions)
163+
access(UpdateSubmissions)
167164
fun remove(challengeType: Type): @{Submission}? {
168165
return <-self.submissions.remove(key: challengeType)
169166
}

src/cadence/contracts/NoopChallenge.cdc renamed to src/cadence/contracts/LearnFlowChallenge.cdc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "GoldStar"
22

33
access(all)
4-
contract NoopChallenge {
4+
contract LearnFlowChallenge {
55

66
access(all)
77
resource Challenge: GoldStar.Challenge {
@@ -13,8 +13,8 @@ contract NoopChallenge {
1313
let description: String
1414

1515
init() {
16-
self.name = "NOOP Challenge"
17-
self.description = "Nothing required for this challenge. All submissions are accepted."
16+
self.name = "Learn Flow"
17+
self.description = "Committed to learning and exploring Flow."
1818
}
1919

2020
access(all)

src/cadence/transactions/NoopChallenge/AddChallenge.cdc renamed to src/cadence/transactions/LearnFlowChallenge/AddChallenge.cdc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "GoldStar"
2-
import "NoopChallenge"
2+
import "LearnFlowChallenge"
33

44
transaction {
55
let admin: &GoldStar.Admin
@@ -10,10 +10,10 @@ transaction {
1010
}
1111

1212
execute {
13-
if GoldStar.challenges[Type<@NoopChallenge.Challenge>()] != nil {
13+
if GoldStar.challenges[Type<@LearnFlowChallenge.Challenge>()] != nil {
1414
return
1515
}
16-
let challenge <- NoopChallenge.createChallenge()
16+
let challenge <- LearnFlowChallenge.createChallenge()
1717
self.admin.addChallenge(<-challenge)
1818
}
1919

src/cadence/transactions/NoopChallenge/Evaluate.cdc renamed to src/cadence/transactions/LearnFlowChallenge/Evaluate.cdc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "GoldStar"
2-
import "NoopChallenge"
2+
import "LearnFlowChallenge"
33

44
transaction {
55
let challengeType: Type
@@ -10,8 +10,8 @@ transaction {
1010
.borrow<auth(GoldStar.UpdateSubmissions) &GoldStar.Profile>(from: GoldStar.profileStoragePath)
1111
?? panic("could not borrow reference to the Profile resource")
1212

13-
let submission <- NoopChallenge.createSubmission()
14-
self.challengeType = Type<@NoopChallenge.Challenge>()
13+
let submission <- LearnFlowChallenge.createSubmission()
14+
self.challengeType = Type<@LearnFlowChallenge.Challenge>()
1515
self.submission = profile.submissions.add(
1616
<-submission,
1717
challengeType: self.challengeType

src/components/ChallengeModal.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Button } from '../ui/design-system/src/lib/Components/Button';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { faBrain } from '@fortawesome/free-solid-svg-icons';
55
import Modal from '@site/src/ui/design-system/src/lib/Components/Modal';
6-
import { submitNoopChallenge } from '../utils/gold-star';
6+
import { submitLearnFlowChallenge } from '../utils/gold-star';
77
import * as fcl from '@onflow/fcl';
88
import { useProfile } from '../hooks/use-profile';
99
import { useCurrentUser } from '../hooks/use-current-user';
@@ -21,7 +21,7 @@ const ChallengeModal: React.FC<{
2121
const completeChallenge = async () => {
2222
setTxStatus('Pending Approval...');
2323
try {
24-
const txId = await submitNoopChallenge();
24+
const txId = await submitLearnFlowChallenge();
2525

2626
setTxStatus('Submitting Challenge...');
2727

@@ -39,7 +39,9 @@ const ChallengeModal: React.FC<{
3939
{
4040
...profile,
4141
submissions: {
42-
[getChallengeIdentifier(GOLD_STAR_CHALLENGES.NOOP_CHALLENGE)]: {
42+
[getChallengeIdentifier(
43+
GOLD_STAR_CHALLENGES.LEARN_FLOW_CHALLENGE,
44+
)]: {
4345
completed: true,
4446
},
4547
},

src/hooks/use-progress.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function useProgress() {
4141
completed:
4242
profile &&
4343
profile.submissions?.[
44-
getChallengeIdentifier(GOLD_STAR_CHALLENGES.NOOP_CHALLENGE)
44+
getChallengeIdentifier(GOLD_STAR_CHALLENGES.LEARN_FLOW_CHALLENGE)
4545
]?.completed,
4646
},
4747
] as ProgressItem[];

src/utils/constants.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export const DISCORD_ANNOUNCEMENTS_CHANNEL_ID = '621529603718119424';
5656
export const DISCORD_DEV_UPDATES_CHANNEL_ID = '811693600403357706';
5757

5858
export const GOLD_STAR_CHALLENGES = {
59-
NOOP_CHALLENGE: {
60-
contractName: 'NoopChallenge',
59+
LEARN_FLOW_CHALLENGE: {
60+
contractName: 'LearnFlowChallenge',
6161
resourceIdentifier: 'Challenge',
6262
},
6363
};

src/utils/gold-star.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import GetChallenges from '../cadence/scripts/GetChallenges.cdc';
22
import GetProfile from '../cadence/scripts/GetProfile.cdc';
33
import CreateProfile from '../cadence/transactions/GoldStar/CreateProfile.cdc';
44
import UpdateProfile from '../cadence/transactions/GoldStar/UpdateProfile.cdc';
5-
import Evaluate from '../cadence/transactions/NoopChallenge/Evaluate.cdc';
5+
import Evaluate from '../cadence/transactions/LearnFlowChallenge/Evaluate.cdc';
66

77
import * as fcl from '@onflow/fcl';
88
import {
@@ -137,10 +137,10 @@ export const setProfile = async (profile: ProfileSettings) => {
137137
};
138138

139139
/**
140-
* Submit a noop challenge
140+
* Submit "Learn Flow" challenge
141141
* @returns The transaction ID
142142
*/
143-
export const submitNoopChallenge = async () => {
143+
export const submitLearnFlowChallenge = async () => {
144144
return await fcl.mutate({
145145
cadence: Evaluate,
146146
});

0 commit comments

Comments
 (0)