forked from sphinx-labs/sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pg): throw an error if contracts are above the size limit
- Loading branch information
1 parent
c7af7ef
commit 52ae5f1
Showing
13 changed files
with
248 additions
and
1 deletion.
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,6 @@ | ||
--- | ||
'@sphinx-labs/plugins': patch | ||
'@sphinx-labs/core': patch | ||
--- | ||
|
||
Throw an error if contracts are above the size limit |
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
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,22 @@ | ||
export const contractsExceedSizeLimitErrorMessage = ( | ||
contracts: Array<{ address: string; fullyQualifiedName?: string }> | ||
): string => { | ||
const contractLines = contracts | ||
.map((contract) => { | ||
let line = `- ` | ||
if (contract.fullyQualifiedName) { | ||
line += `${contract.fullyQualifiedName} at ` | ||
} | ||
line += `${contract.address}` | ||
if (!contract.fullyQualifiedName) { | ||
line += ' (unlabeled)' | ||
} | ||
return line | ||
}) | ||
.join('\n') | ||
|
||
return ( | ||
`The following contracts are over the contract size limit (24,576 bytes), which means they\n` + | ||
`cannot be deployed on live networks:\n${contractLines}` | ||
) | ||
} |
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,25 @@ | ||
import { expect } from 'chai' | ||
|
||
import { contractsExceedSizeLimitErrorMessage } from '../../src/error-messages' | ||
|
||
describe('Error Messages', () => { | ||
it('contractsExceedSizeLimitErrorMessage', () => { | ||
const contracts = [ | ||
{ | ||
address: '0xABCDEF1234567890ABCDEF1234567890ABCDEF12', | ||
fullyQualifiedName: 'contracts/ExampleContract.sol:ExampleContract', | ||
}, | ||
{ address: '0x1234567890ABCDEF1234567890ABCDEF12345678' }, // Unlabeled | ||
] | ||
// eslint-disable-next-line prettier/prettier | ||
const expectedMessage = | ||
`The following contracts are over the contract size limit (24,576 bytes), which means they | ||
cannot be deployed on live networks: | ||
- contracts/ExampleContract.sol:ExampleContract at 0xABCDEF1234567890ABCDEF1234567890ABCDEF12 | ||
- 0x1234567890ABCDEF1234567890ABCDEF12345678 (unlabeled)` | ||
|
||
const actualMessage = contractsExceedSizeLimitErrorMessage(contracts) | ||
|
||
expect(actualMessage).to.equal(expectedMessage) | ||
}) | ||
}) |
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