Skip to content

Commit

Permalink
make compiler output artifact linkReferences optional (for 0.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
merklejerk committed Mar 16, 2022
1 parent 41976dd commit c44fb80
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 6 deletions.
9 changes: 9 additions & 0 deletions abi-gen/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "5.8.0",
"changes": [
{
"note": "Handle potentially missing linkReferences in 0.8",
"pr": 62
}
]
},
{
"timestamp": 1647412162,
"version": "5.7.4",
Expand Down
2 changes: 1 addition & 1 deletion abi-gen/templates/TypeScript/contract.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class {{contractName}}Contract extends BaseContract {
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
const links = artifact.compilerOutput.evm.bytecode.linkReferences || {};
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
Expand Down
2 changes: 1 addition & 1 deletion abi-gen/test-cli/output/typescript/abi_gen_dummy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ export class AbiGenDummyContract extends BaseContract {
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
const links = artifact.compilerOutput.evm.bytecode.linkReferences || {};
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
Expand Down
2 changes: 1 addition & 1 deletion abi-gen/test-cli/output/typescript/lib_dummy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class LibDummyContract extends BaseContract {
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
const links = artifact.compilerOutput.evm.bytecode.linkReferences || {};
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
Expand Down
2 changes: 1 addition & 1 deletion abi-gen/test-cli/output/typescript/test_lib_dummy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class TestLibDummyContract extends BaseContract {
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
const links = artifact.compilerOutput.evm.bytecode.linkReferences || {};
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
Expand Down
9 changes: 9 additions & 0 deletions base-contract/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "6.5.0",
"changes": [
{
"note": "Handle potentially missing `linkReferences` in generated artifacts",
"pr": 62
}
]
},
{
"timestamp": 1647412162,
"version": "6.4.7",
Expand Down
2 changes: 1 addition & 1 deletion base-contract/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function linkLibrariesInBytecode(
): string {
const bytecodeArtifact = artifact.compilerOutput.evm.bytecode;
let bytecode = bytecodeArtifact.object.substr(2);
for (const link of Object.values(bytecodeArtifact.linkReferences)) {
for (const link of Object.values(bytecodeArtifact.linkReferences || {})) {
for (const [libraryName, libraryRefs] of Object.entries(link)) {
const libraryAddress = libraryAddresses[libraryName];
if (!libraryAddress) {
Expand Down
9 changes: 9 additions & 0 deletions ethereum-types/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "3.7.0",
"changes": [
{
"note": "Make compiler artifact `linkReferences` optional",
"pr": 62
}
]
},
{
"timestamp": 1645908702,
"version": "3.6.1",
Expand Down
2 changes: 1 addition & 1 deletion ethereum-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export interface EvmOutput {
}

export interface EvmBytecodeOutput {
linkReferences: EvmBytecodeOutputLinkReferences;
linkReferences?: EvmBytecodeOutputLinkReferences;
object: string;
sourceMap: string;
}
Expand Down

0 comments on commit c44fb80

Please sign in to comment.