-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe0c38b
commit 6596131
Showing
19 changed files
with
269 additions
and
21 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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2022 SmartContract ChainLink, Ltd. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,17 @@ | ||
# Gauntlet Starknet Commands for LINK Token | ||
|
||
## Bridge | ||
|
||
All register/remove admin commands follow the same format | ||
|
||
```bash | ||
yarn gauntlet bridge:<REGISTER_OR_REMOVE_COMMAND> --account=<ADMIN_TO_REGISTER_OR_REMOVE> <CONTRACT> | ||
``` | ||
|
||
Example: | ||
```bash | ||
yarn gauntlet bridge:register_governance_admin --account=<ADMIN_TO_REGISTER> <L2_BRIDGE_CONTRACT> | ||
``` | ||
|
||
|
||
|
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,31 @@ | ||
{ | ||
"name": "@chainlink/starknet-gauntlet-bridge", | ||
"version": "0.0.1", | ||
"description": "Gauntlet Starknet Starkgate Bridge", | ||
"keywords": [ | ||
"typescript", | ||
"cli" | ||
], | ||
"main": "./dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*", | ||
"!dist/**/*.test.js" | ||
], | ||
"scripts": { | ||
"gauntlet": "ts-node ./src/index.ts", | ||
"lint": "tsc", | ||
"format": "yarn prettier --write ./src", | ||
"format:check": "yarn prettier --check ./src", | ||
"clean": "rm -rf ./dist/ ./bin/", | ||
"build": "yarn clean && tsc -b", | ||
"bundle": "yarn build && pkg ." | ||
}, | ||
"dependencies": { | ||
"@chainlink/evm-gauntlet": "^0.4.0", | ||
"@chainlink/gauntlet-core": "0.3.1", | ||
"@chainlink/starknet-gauntlet": "*", | ||
"@chainlink/starknet-gauntlet-oz": "*", | ||
"ethers": "^5.6.9" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages-ts/starknet-gauntlet-bridge/src/commands/bridge/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import RegisterGovernanceAdmin from './registerGovernanceAdmin' | ||
import RemoveGovernanceAdmin from './removeGovernanceAdmin' | ||
import RemoveSecurityAdmin from './removeSecurityAdmin' | ||
import RemoveUpgradeGovernor from './removeUpgradeGovernor' | ||
|
||
export default [RegisterGovernanceAdmin, RemoveGovernanceAdmin, RemoveSecurityAdmin, RemoveUpgradeGovernor] |
8 changes: 8 additions & 0 deletions
8
packages-ts/starknet-gauntlet-bridge/src/commands/bridge/registerGovernanceAdmin.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { | ||
makeExecuteCommand, | ||
} from '@chainlink/starknet-gauntlet' | ||
import { createRegisterAdminCommandConfig } from '../../lib/createAdminCommand' | ||
|
||
const commandConfig = createRegisterAdminCommandConfig('register_governance_admin') | ||
|
||
export default makeExecuteCommand(commandConfig) |
8 changes: 8 additions & 0 deletions
8
packages-ts/starknet-gauntlet-bridge/src/commands/bridge/removeGovernanceAdmin.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { | ||
makeExecuteCommand, | ||
} from '@chainlink/starknet-gauntlet' | ||
import { createRemoveAdminCommandConfig } from '../../lib/createAdminCommand' | ||
|
||
const commandConfig = createRemoveAdminCommandConfig('remove_governance_admin') | ||
|
||
export default makeExecuteCommand(commandConfig) |
8 changes: 8 additions & 0 deletions
8
packages-ts/starknet-gauntlet-bridge/src/commands/bridge/removeSecurityAdmin.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { | ||
makeExecuteCommand, | ||
} from '@chainlink/starknet-gauntlet' | ||
import { createRemoveAdminCommandConfig } from '../../lib/createAdminCommand' | ||
|
||
const commandConfig = createRemoveAdminCommandConfig('remove_security_admin') | ||
|
||
export default makeExecuteCommand(commandConfig) |
8 changes: 8 additions & 0 deletions
8
packages-ts/starknet-gauntlet-bridge/src/commands/bridge/removeUpgradeGovernor.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { | ||
makeExecuteCommand, | ||
} from '@chainlink/starknet-gauntlet' | ||
import { createRemoveAdminCommandConfig } from '../../lib/createAdminCommand' | ||
|
||
const commandConfig = createRemoveAdminCommandConfig('remove_upgrade_governor') | ||
|
||
export default makeExecuteCommand(commandConfig) |
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,3 @@ | ||
import Bridge from './bridge' | ||
|
||
export const L2Commands = [...Bridge] |
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,3 @@ | ||
import { L2Commands } from './commands' | ||
|
||
export { L2Commands } |
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,5 @@ | ||
import { CONTRACT_LIST } from './contracts' | ||
|
||
export const CATEGORIES = { | ||
BRIDGE: CONTRACT_LIST.BRIDGE, | ||
} |
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,11 @@ | ||
import { loadContractByPath } from '@chainlink/starknet-gauntlet' | ||
|
||
export enum CONTRACT_LIST { | ||
BRIDGE = 'bridge', | ||
} | ||
|
||
export const bridgeContractLoader = () => | ||
loadContractByPath( | ||
`${__dirname}/../../artifacts/bridge/TokenBridge.contract_class.json`, | ||
`${__dirname}/../../artifacts/bridge/TokenBridge.compiled_contract_class.json`, | ||
) |
94 changes: 94 additions & 0 deletions
94
packages-ts/starknet-gauntlet-bridge/src/lib/createAdminCommand.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { | ||
BeforeExecute, | ||
isValidAddress, | ||
} from '@chainlink/starknet-gauntlet' | ||
import { uint256 } from 'starknet' | ||
import { CATEGORIES } from './categories' | ||
import { bridgeContractLoader, CONTRACT_LIST } from './contracts' | ||
|
||
type UserInput = { | ||
account: string | ||
} | ||
|
||
type ContractInput = [account: string] | ||
|
||
const makeUserInput = async (flags, args): Promise<UserInput> => { | ||
if (flags.input) return flags.input as UserInput | ||
|
||
return { | ||
account: flags.account, | ||
} | ||
} | ||
|
||
const validateAccount = async (input) => { | ||
if (!isValidAddress(input.account)) throw new Error(`Invalid account address: ${input.account}`) | ||
return true | ||
} | ||
|
||
const makeContractInput = async (input: UserInput): Promise<ContractInput> => { | ||
return [input.account] | ||
} | ||
|
||
const beforeAdminRemoveExecute: BeforeExecute<UserInput, ContractInput> = ( | ||
context, | ||
input, | ||
deps, | ||
) => async () => { | ||
|
||
deps.logger.info( | ||
`About to remove admin ${input.user.account} for l2 bridge ${context.contractAddress}`, | ||
) | ||
} | ||
|
||
const beforeAdminRegisterExecute: BeforeExecute<UserInput, ContractInput> = ( | ||
context, | ||
input, | ||
deps, | ||
) => async () => { | ||
|
||
deps.logger.info( | ||
`About to register admin ${input.user.account} for l2 bridge ${context.contractAddress}`, | ||
) | ||
} | ||
|
||
export const createRegisterAdminCommandConfig = (action: string) => { | ||
return { | ||
contractId: CONTRACT_LIST.BRIDGE, | ||
category: CATEGORIES.BRIDGE, | ||
action, | ||
ux: { | ||
description: 'Registers admin', | ||
examples: [ | ||
`${CATEGORIES.BRIDGE}:${action} --network=<NETWORK> --account=<ADMIN> <CONTRACT_ADDRESS>`, | ||
], | ||
}, | ||
makeUserInput, | ||
makeContractInput, | ||
validations: [validateAccount], | ||
loadContract: bridgeContractLoader, | ||
hooks: { | ||
beforeExecute: beforeAdminRegisterExecute, | ||
}, | ||
} | ||
} | ||
|
||
export const createRemoveAdminCommandConfig = (action: string) => { | ||
return { | ||
contractId: CONTRACT_LIST.BRIDGE, | ||
category: CATEGORIES.BRIDGE, | ||
action, | ||
ux: { | ||
description: 'Removes admin', | ||
examples: [ | ||
`${CATEGORIES.BRIDGE}:${action} --network=<NETWORK> --account=<ADMIN> <CONTRACT_ADDRESS>`, | ||
], | ||
}, | ||
makeUserInput, | ||
makeContractInput, | ||
validations: [validateAccount], | ||
loadContract: bridgeContractLoader, | ||
hooks: { | ||
beforeExecute: beforeAdminRemoveExecute, | ||
}, | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["dist", "**/*.spec.ts", "**/*.test.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
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