Skip to content

Commit

Permalink
configure testnet deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline committed Aug 24, 2024
1 parent b4afaf2 commit 2f12929
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Flow dependencies
run: npm i
- name: Install Flow CLI
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)"
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Run tests
run: |
./run-tests.sh
Expand Down
28 changes: 28 additions & 0 deletions contracts/CapabilityCache.cdc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
https://github.com/Flowtyio/capability-cache
CapabilityCache helps manage capabilities which are issued but are not in public paths.
Rather than looping through all capabilities under a storage path and finding one that
matches the Capability type you want, the cache can be used to retrieve them
*/
access(all) contract CapabilityCache {

access(all) let basePathIdentifier: String
Expand All @@ -17,6 +24,8 @@ access(all) contract CapabilityCache {
// Resource that manages capabilities for a provided namespace. Only one capability is permitted per type.
access(all) resource Cache {
access(self) let caps: {Type: Capability}
access(self) let ids: {UInt64: Type}

access(all) let namespace: String

// Remove a capability, if it exists,
Expand All @@ -32,7 +41,12 @@ access(all) contract CapabilityCache {
// Adds a capability to the cache. If there is already an entry for the given type,
// it will be returned
access(Add) fun addCapability(cap: Capability, type: Type): Capability? {
pre {
cap.id != 0: "cannot add a capability with id 0"
}

emit CapabilityAdded(owner: self.owner?.address, cacheUuid: self.uuid, namespace: self.namespace, capabilityType: type, capabilityID: cap.id)
self.ids[cap.id] = type
return self.caps.insert(key: type, cap)
}

Expand All @@ -41,8 +55,22 @@ access(all) contract CapabilityCache {
return self.caps[type]
}

access(all) fun getTypes(): [Type] {
return self.caps.keys

Check warning on line 59 in contracts/CapabilityCache.cdc

View check run for this annotation

Codecov / codecov/patch

contracts/CapabilityCache.cdc#L59

Added line #L59 was not covered by tests
}

access(all) fun getIDs(): [UInt64] {
return self.ids.keys

Check warning on line 63 in contracts/CapabilityCache.cdc

View check run for this annotation

Codecov / codecov/patch

contracts/CapabilityCache.cdc#L63

Added line #L63 was not covered by tests
}

access(all) fun getIdByType(_ id: UInt64): Type? {
return self.ids[id]

Check warning on line 67 in contracts/CapabilityCache.cdc

View check run for this annotation

Codecov / codecov/patch

contracts/CapabilityCache.cdc#L67

Added line #L67 was not covered by tests
}

init(namespace: String) {
self.caps = {}
self.ids = {}

self.namespace = namespace
}
}
Expand Down
15 changes: 15 additions & 0 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"type": "file",
"location": "emulator-account.pkey"
}
},
"testnet-account": {
"address": "0x6340b2ab38404605",
"key": {
"type": "google-kms",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/flowty-test/locations/global/keyRings/flow/cryptoKeys/capability-cache/cryptoKeyVersions/1"
}
}
},
"contracts": {
Expand Down Expand Up @@ -108,6 +118,11 @@
"emulator-flowtoken": [
"FlowToken"
]
},
"testnet": {
"testnet-account": [
"CapabilityCache"
]
}
}
}

0 comments on commit 2f12929

Please sign in to comment.