-
Notifications
You must be signed in to change notification settings - Fork 48
Migration tool #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Migration tool #21
Changes from all commits
Commits
Show all changes
178 commits
Select commit
Hold shift + click to select a range
ed706c8
Initial commit
sshmaxime c07d1b3
Merge branch 'master' of github.com:bancorprotocol/contracts-v3 into …
sshmaxime 13342ef
Rework architecture + adding docs
sshmaxime eef9a6b
Update README.md + few folder organizations
sshmaxime bfd5ccb
Merge branch 'master' of github.com:bancorprotocol/contracts-v3 into …
sshmaxime 36550b2
Architecture folder reorg + add info to README
sshmaxime c550026
README.md correction
sshmaxime e1ba9a4
Merge branch 'master' of github.com:bancorprotocol/contracts-v3 into …
sshmaxime 9039d24
Minor fixes
sshmaxime 8cd399b
Few fixes
sshmaxime 961116d
Update README.md
sshmaxime 910e146
add description to readme.md
sshmaxime ed939e8
Fixed issues + renamed files + change forking methods
sshmaxime 2fa84e8
Merge branch 'master' of github.com:bancorprotocol/contracts-v3 into …
sshmaxime aeb5b5a
Merge branch 'master' of github.com:bancorprotocol/contracts-v3 into …
sshmaxime 820d1e2
Architecture re organization + improvement for fork used + bunch of o…
sshmaxime e4635f1
update config.json in readme
sshmaxime 7ddaad0
Added mainnet network info + optimization + better handling of migrat…
sshmaxime 23d65ef
Fix issues + update README.md + optimizations
sshmaxime b38e48f
Add proxy to engine + add initial contract migrations
sshmaxime b454232
pass deploy & execute to initProxy
sshmaxime 23dde3d
fix typos
sshmaxime 771ce17
optimization of network forking use
sshmaxime 5a28679
Add log default param + added atomical initialization
sshmaxime 8501645
Typos + quick fixes
sshmaxime a20d5d9
few typos + readme.md updates
sshmaxime 1e418c4
typos
sshmaxime 7366b93
separate initial contract migration to several ones
sshmaxime a4ce37a
Add healthcheck for each migration
sshmaxime 2ee78d5
fix log errors
sshmaxime 05da0c8
fix typos filename
sshmaxime 935a392
fix typos filename
sshmaxime dc7af33
fix migration + optimization + update hh typechain
sshmaxime 417bb18
add migration errors + typos
sshmaxime 454c0c3
improve code architecture
sshmaxime 5719a90
re-architecture + put tasks in specific folder outside engine
sshmaxime 11959cc
typos fix
sshmaxime 7e3b068
Add down to migration
sshmaxime f80df80
few updates
sshmaxime 5d48407
fix error due to london fork + fix typos + merge master
sshmaxime 831f67a
update yarn.lock
sshmaxime 602cfb3
WIP: fix errors due to typechain
sshmaxime 3d81df3
merge with master
sshmaxime 7b1a041
add deploy basics contracts migration + update mainnet state + add to…
sshmaxime 926c41e
put comments to the norm
sshmaxime 8fad5f4
fix dependency problem with @bancor/token-governance
sshmaxime c626bd1
typos fix + update hh config
sshmaxime a729a83
Update forking description
sshmaxime d7a2c5b
WIP: typos
sshmaxime 3478a61
fix typos + add revert logic
sshmaxime 2310399
fix revert mechanism
sshmaxime 4e8fc90
fix typos + improve log function
sshmaxime 2594e5b
remove custom errors on migration executions
sshmaxime f5411ab
typos
sshmaxime 3cba5a1
update throw errors + typos + add upgradeProxy
sshmaxime d6484af
Improve logs
sshmaxime 9782367
Add upgrade network settings
sshmaxime 08ce64e
merge master into branch
sshmaxime 94d7675
fix revert to last success
sshmaxime fee573f
remove useless log
sshmaxime f21746e
re-architecture
sshmaxime d32024b
update readme.md
sshmaxime 0f61f14
pass migration config to healthcheck in order to act healthcheck base…
sshmaxime 14666e1
typos
sshmaxime d0ecada
add abi and bytecode in contract builder
sshmaxime 66451b8
Re-architecture of the migration tool in order to facilitate development
sshmaxime e00bc84
healthcheck of engine in function
sshmaxime 08295d8
fix reset not working due to engine
sshmaxime b5340a4
WIP: improve migration management + add ABI + bytecode storage on con…
sshmaxime 9d552db
improved class + split deployment by migrations
sshmaxime f6781bc
update readme
sshmaxime b45cef9
add loader
sshmaxime 3c87a16
fix: add loader
sshmaxime 239c971
add feature in readme
sshmaxime 5024dd6
add word list ability to create migrations + improve overall architec…
sshmaxime 1c5ee4c
add tests + fix typos + add custom console
sshmaxime 9046ab0
fix logging
sshmaxime 0774074
Add migration exemples + add rinkeby data folder + update README.md +…
sshmaxime 79b8ea0
update token-governance dep + improve extended config + add readme.md…
sshmaxime 281ea01
few fixes
sshmaxime f454996
remove useless exemples + remove custom timestamp + renamed files wit…
sshmaxime c102576
change error message
sshmaxime 4e6bcc4
Don't continue the migration after a reset
lbeder a42bea1
constant --> Constants
lbeder ab15b1e
Temp rename
lbeder 9c80e0e
engine --> Engine
lbeder c27262a
Refactor
lbeder b7af9f1
Temp rename
lbeder b0626fb
executionFunctions --> ExecutionFunctions
lbeder fc3cc69
Refactor
lbeder 17c1753
Style
lbeder 49aaadb
Temp rename
lbeder 1b637a6
Replacer + style
lbeder 88627f6
Temp rename
lbeder b754723
Capitalize
lbeder 843fe0e
Style
lbeder b4c711f
Temp rename
lbeder 3491d9e
Capitalize
lbeder 38823f5
Style
lbeder a4c005e
Temp rename
lbeder 9c528e1
Capitalize
lbeder e1fc2ef
Style
lbeder 4689fef
Temp rename
lbeder 87447fa
Capitalize
lbeder e66a53c
Temp rename
lbeder 296017f
Capitalize
lbeder c9645eb
Style
lbeder ec58f26
FOLDER --> DIR
lbeder 9a9a279
FOLDER --> DIR
lbeder 2feb578
Refactor
lbeder 21b4815
Style
lbeder e5389ed
Style
lbeder 5b36fc9
exemples --> examples
lbeder d602116
Style
lbeder affef12
Style
lbeder 97b141f
Temp rename
lbeder 690c3b3
Capitalize
lbeder 2a35e1b
Style
lbeder f9f8949
Temp rename
lbeder 97bec05
Capitalize
lbeder 2ec65c6
Temp rename
lbeder 3735cfd
Capitalize
lbeder f70e073
ExecutionFunctions --> Execution
lbeder 1df4f5f
Style
lbeder 85fbc2c
Rename
lbeder c3a574c
Style
lbeder 1382ee4
Style
lbeder f2e7f1e
Temp rename
lbeder 90c4766
Capitalize
lbeder 01af55b
Rename
lbeder de239b5
Style
lbeder 4534c36
Style
lbeder 4659d09
Style
lbeder 26b2b90
Merge branch 'migration_tool' into migration-tool-refactor
lbeder bc7fcf4
Style
lbeder d7b2498
Fix tests
lbeder 8f2f4c3
Fix loop
lbeder ca987c3
Combine reset and migrate
lbeder f63a70a
Typo
lbeder 946e27b
Folder --> Dir
lbeder 2df56bd
initializeFctName --> initializeFunction
lbeder 8859a07
Remove pathToRoot
lbeder c192a26
Copy
lbeder cac8af0
Copy
lbeder c1f2661
Copy
lbeder f210f30
Copy
lbeder 6879f68
Add error message
lbeder 6c25500
Copy
lbeder dd8b0d9
Copy
lbeder 14c2442
Copy
lbeder 1b3f0cd
Refactor
lbeder 9579ea1
add test migration to CI
sshmaxime 24daf73
Merge pull request #81 from bancorprotocol/migration-tool-refactor
lbeder 5c1b891
undo changes regarding governance contracts and system tokens
sshmaxime 0ded0e4
fix undo
sshmaxime e6c5a29
typo
sshmaxime cc4bf56
remove outdated migration
sshmaxime e940c99
added legacy contracts + added tokengovernance to create system
sshmaxime 90e246e
fix yarn package
sshmaxime 44e505b
create migrations dir if it doesn't exist
sshmaxime 52c5ede
Merge branch 'migration_tool' of github.com:bancorprotocol/contracts-…
sshmaxime faea684
fix yarn.lock
sshmaxime d39e333
add legacy BNT and vBNT tokens
sshmaxime 448bcc3
add npm package as dependencies instead of github repo in v2 package
sshmaxime f9b48d1
fix dep path
sshmaxime ee95191
add NetworkToken & GovToken project wide
sshmaxime a5ed603
update tests with correct error messages
sshmaxime d5cfc3d
update throw error message to match with the real contracts
sshmaxime dac5adc
differenciate error message for BNT and TKN
sshmaxime 84b4334
add new line
sshmaxime 2ecb2f3
remove TestSystemToken
sshmaxime 7fa4b10
update throw message
sshmaxime 25b3cb8
additional fix
sshmaxime 1244f20
add utils functions for reserveToken errors
sshmaxime 06e74c9
typos
sshmaxime ad2a840
add error case for vBNT
sshmaxime a79ecf5
typo
sshmaxime 183b276
Merge pull request #83 from bancorprotocol/legacy_contracts
sshmaxime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -35,3 +35,6 @@ jobs: | |
|
||
- name: Test | ||
run: CI=1 yarn test | ||
|
||
- name: Test Migration | ||
run: CI=1 yarn test-migration |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,62 @@ | ||
/* eslint-enable camelcase */ | ||
import { Signer } from '@ethersproject/abstract-signer'; | ||
import { ContractFactory } from '@ethersproject/contracts'; | ||
import { ethers } from 'hardhat'; | ||
|
||
type AsyncReturnType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer U> | ||
? U | ||
: T extends (...args: any) => infer U | ||
? U | ||
: any; | ||
|
||
export type Contract<F extends ContractFactory> = AsyncReturnType<F['deploy']>; | ||
|
||
export interface ContractBuilder<F extends ContractFactory> { | ||
metadata: { | ||
contractName: string; | ||
abi: unknown; | ||
bytecode: string; | ||
}; | ||
deploy(...args: Parameters<F['deploy']>): Promise<Contract<F>>; | ||
attach(address: string, signer?: Signer): Promise<Contract<F>>; | ||
} | ||
|
||
export type FactoryConstructor<F extends ContractFactory> = { | ||
new (signer?: Signer): F; | ||
abi: unknown; | ||
bytecode: string; | ||
}; | ||
|
||
export const deployOrAttach = <F extends ContractFactory>( | ||
contractName: string, | ||
// @TODO: needs to replace with correctly typed params but it doesn't | ||
// work properly for some reason https://github.com/microsoft/TypeScript/issues/31278 | ||
FactoryConstructor: FactoryConstructor<F>, | ||
initialSigner?: Signer | ||
): ContractBuilder<F> => { | ||
return { | ||
metadata: { | ||
contractName: contractName, | ||
abi: FactoryConstructor.abi, | ||
bytecode: FactoryConstructor.bytecode | ||
}, | ||
deploy: async (...args: Parameters<F['deploy']>): Promise<Contract<F>> => { | ||
const defaultSigner = initialSigner || (await ethers.getSigners())[0]; | ||
|
||
return new FactoryConstructor(defaultSigner).deploy(...(args || [])) as Contract<F>; | ||
}, | ||
attach: attachOnly<F>(FactoryConstructor, initialSigner).attach | ||
}; | ||
}; | ||
|
||
export const attachOnly = <F extends ContractFactory>( | ||
FactoryConstructor: FactoryConstructor<F>, | ||
initialSigner?: Signer | ||
) => { | ||
return { | ||
attach: async (address: string, signer?: Signer): Promise<Contract<F>> => { | ||
const defaultSigner = initialSigner || (await ethers.getSigners())[0]; | ||
return new FactoryConstructor(signer || defaultSigner).attach(address) as Contract<F>; | ||
} | ||
}; | ||
}; |
This file contains hidden or 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 hidden or 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,26 @@ | ||
/* eslint-disable camelcase */ | ||
import { deployOrAttach } from './ContractBuilder'; | ||
import { | ||
TokenGovernance__factory, | ||
SmartToken__factory as NetworkToken__factory, | ||
SmartToken as NetworkToken, | ||
DSToken__factory as GovToken__factory, | ||
DSToken as GovToken | ||
} from '@bancor/token-governance'; | ||
import { Signer } from '@ethersproject/abstract-signer'; | ||
|
||
export { NetworkToken, GovToken }; | ||
|
||
/* eslint-enable camelcase */ | ||
|
||
const getContracts = (signer?: Signer) => ({ | ||
connect: (signer: Signer) => getContracts(signer), | ||
|
||
TokenGovernance: deployOrAttach('TokenGovernance', TokenGovernance__factory, signer), | ||
NetworkToken: deployOrAttach('BNTToken', NetworkToken__factory, signer), | ||
GovToken: deployOrAttach('vBNTToken', GovToken__factory, signer) | ||
}); | ||
|
||
export type ContractsType = ReturnType<typeof getContracts>; | ||
|
||
export default getContracts(); |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.