-
Notifications
You must be signed in to change notification settings - Fork 96
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
Scripts enhancements #1321
Merged
Merged
Scripts enhancements #1321
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2e10795
Added checks to validate target deployment address matches mainnet
smartcontrart 9ae5dbd
Added storing of commit hashes upon deployment to track deployed code
smartcontrart 58c64e3
Created script to populate the latest deploy commits
smartcontrart f4ccda1
Renamed deploy commits script for clarity
smartcontrart c565157
Updated module declarations
smartcontrart a857993
Removed script to populate hashes
smartcontrart 636b15b
prompt language update
dmosites 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 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,83 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const { execSync } = require('child_process') | ||
|
||
const subfolders = [ | ||
'batch-call', | ||
'delegate', | ||
'pool', | ||
'registry', | ||
'staking', | ||
'swap', | ||
'swap-erc20', | ||
'wrapper', | ||
] | ||
|
||
function getLatestCommitForContract(contractPath) { | ||
const branches = ['main', 'develop'] | ||
for (const branch of branches) { | ||
try { | ||
const commit = execSync( | ||
`git log -1 --format=%H ${branch} -- ${contractPath}/contracts` | ||
) | ||
.toString() | ||
.trim() | ||
let tag | ||
try { | ||
tag = execSync(`git describe --tags --contains ${commit}`) | ||
.toString() | ||
.trim() | ||
.split('-')[0] // Get the most recent tag | ||
} catch { | ||
tag = 'No tag found' | ||
} | ||
return { branch, tag, commit } | ||
} catch (error) { | ||
// No changes in this branch, continue to the next one | ||
} | ||
} | ||
return { | ||
branch: 'No branch found', | ||
tag: 'No tag found', | ||
commit: 'No commit found', | ||
} | ||
} | ||
|
||
const repoUrl = 'https://github.com/airswap/airswap-protocols' | ||
|
||
subfolders.forEach((folder) => { | ||
const contractPath = path.join('source', folder) | ||
const deploysBlocksPath = path.join( | ||
__dirname, | ||
contractPath, | ||
'deploys-blocks.js' | ||
) | ||
const deploysCommitsPath = path.join( | ||
__dirname, | ||
contractPath, | ||
'deploys-commits.js' | ||
) | ||
|
||
const deploysBlocks = require(deploysBlocksPath) | ||
const { branch, tag, commit } = getLatestCommitForContract(contractPath) | ||
|
||
console.log(`Contract: ${folder}`) | ||
console.log(`Branch: ${branch}`) | ||
console.log(`Latest tag: ${tag}`) | ||
console.log(`Commit: ${commit}`) | ||
console.log(`Commit link: ${repoUrl}/commit/${commit}`) | ||
console.log('---') | ||
|
||
let content = 'module.exports = {\n' | ||
|
||
Object.keys(deploysBlocks).forEach((chainId) => { | ||
content += ` ${chainId}: '${commit}',\n` | ||
}) | ||
|
||
content += '}\n' | ||
|
||
fs.writeFileSync(deploysCommitsPath, content) | ||
console.log(`Updated ${deploysCommitsPath}`) | ||
}) | ||
|
||
console.log('All deploys-commits.js files have been updated successfully.') |
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,19 @@ | ||
module.exports = { | ||
1: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
31: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
41: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
56: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
97: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
137: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
8453: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
17000: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
42161: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
43113: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
43114: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
59140: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
59144: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
80001: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
84532: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
421614: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
11155111: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
} |
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 @@ | ||
declare module '@airswap/batch-call/deploys-commits.js' |
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,3 @@ | ||
module.exports = { | ||
11155111: 'da05cb9528630f4f2e15ce3f9093b0f944bec1b7', | ||
} |
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 @@ | ||
declare module '@airswap/batch-call/deploys-commits.js' |
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,22 @@ | ||
module.exports = { | ||
1: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
5: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
30: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
31: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
40: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
41: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
56: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
97: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
137: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
8453: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
17000: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
42161: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
43113: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
43114: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
59140: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
59144: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
80001: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
84531: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
421613: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
11155111: 'a535d0bb280fdb603a903dd2ae94e6b27d66b3d4', | ||
} |
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 @@ | ||
declare module '@airswap/batch-call/deploys-commits.js' |
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,19 @@ | ||
module.exports = { | ||
1: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
31: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
41: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
56: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
97: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
137: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
8453: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
17000: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
42161: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
43113: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
43114: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
59140: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
59144: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
80001: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
84532: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
421614: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
11155111: '863586ae7594b5088619f243dbee83c8d8e0075f', | ||
} |
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 @@ | ||
declare module '@airswap/batch-call/deploys-commits.js' |
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,5 @@ | ||
module.exports = { | ||
1: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab', | ||
17000: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab', | ||
11155111: '6ede424741588b8e3fbb8060cc9ee8d343eac4ab', | ||
} |
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 @@ | ||
declare module '@airswap/batch-call/deploys-commits.js' |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check
${contractPath}/contracts/deploys.js
specifically.