-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #636 from threshold-network/feature/authorization-…
…events-update Update contract for AuthorizationIncreased event tBTC and RB app contracts define `AuthorizationIncreased` events with the exact signature than those from the staking contract, so for their particular case, listening for app events work. However, this is problematic for the TACo app contract that doesn't define them in the same way. For the sake of consistency contract-providing hook (`useStakingAppContract` to `useTStakingContract`) has been replaced. Moreover `getStakingAppLabel` utility set has been refactored with unit tests included.
- Loading branch information
Showing
8 changed files
with
88 additions
and
27 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
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
20 changes: 10 additions & 10 deletions
20
src/hooks/staking-applications/useSubscribeToAuthorizationIncreasedEvent.ts
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
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,56 @@ | ||
import { | ||
getStakingAppLabelFromAppAddress, | ||
getStakingAppLabelFromAppName, | ||
getStakingAppNameFromAppAddress, | ||
} from "../getStakingAppLabel" | ||
import { StakingAppName } from "../../store/staking-applications" | ||
import { getThresholdLib } from "../getThresholdLib" | ||
|
||
const mockAddresses: Record<StakingAppName, string> = { | ||
tbtc: getThresholdLib().multiAppStaking.ecdsa.address, | ||
randomBeacon: getThresholdLib().multiAppStaking.randomBeacon.address, | ||
} | ||
const mockLabels: Record<StakingAppName, string> = { | ||
tbtc: "tBTC", | ||
randomBeacon: "Random Beacon", | ||
} | ||
const mockAppNames: StakingAppName[] = ["tbtc", "randomBeacon"] | ||
|
||
describe("Staking app label utils tests", () => { | ||
const [tbtcName, randomBeaconName] = mockAppNames | ||
const tbtcAddress = mockAddresses[tbtcName] | ||
const randomBeaconAddress = mockAddresses[randomBeaconName] | ||
|
||
it("returns correct app label if app address is given", () => { | ||
const resultTbtcLabel = getStakingAppLabelFromAppAddress(tbtcAddress) | ||
const resultRandomBeaconLabel = | ||
getStakingAppLabelFromAppAddress(randomBeaconAddress) | ||
|
||
expect(resultTbtcLabel).toBe(mockLabels[tbtcName]) | ||
expect(resultRandomBeaconLabel).toBe(mockLabels[randomBeaconName]) | ||
}) | ||
|
||
it("returns correct app label if app name is given", () => { | ||
const resultTbtcLabel = getStakingAppLabelFromAppName(tbtcName) | ||
const resultRandomBeaconLabel = | ||
getStakingAppLabelFromAppName(randomBeaconName) | ||
|
||
expect(resultTbtcLabel).toBe(mockLabels[tbtcName]) | ||
expect(resultRandomBeaconLabel).toBe(mockLabels[randomBeaconName]) | ||
}) | ||
|
||
it("returns correct app name if address is given", () => { | ||
const resultTbtcName = getStakingAppNameFromAppAddress(tbtcAddress) | ||
const resultRandomBeaconName = | ||
getStakingAppNameFromAppAddress(randomBeaconAddress) | ||
|
||
expect(resultTbtcName).toBe(tbtcName) | ||
expect(resultRandomBeaconName).toBe(randomBeaconName) | ||
}) | ||
|
||
it("returns fallback value if address is unexpected", () => { | ||
const resultName = getStakingAppLabelFromAppAddress("0xun3xp3c73d400r3s5") | ||
|
||
expect(resultName).toBe("App") | ||
}) | ||
}) |
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