-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a
deployInstance
method to contract factories generated b…
…y typegen (#1160) * feat: export contract bytecode from typegen * feat: add `deployInstance` method to typegen * add changeset * Update runTypegen.test.ts * rename `deployInstance` to `deployContract` * add docs
- Loading branch information
Showing
14 changed files
with
158 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@fuel-ts/abi-typegen": patch | ||
--- | ||
|
||
Add `deployContract` method to contract factories generated via typegen |
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,3 @@ | ||
{{header}} | ||
|
||
export default '{{hexlifiedBytecode}}' |
24 changes: 24 additions & 0 deletions
24
packages/abi-typegen/src/templates/contract/bytecode.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ForcProjectsEnum, getProjectResources } from '../../../test/fixtures/forc-projects'; | ||
import bytecodeTemplte from '../../../test/fixtures/templates/contract/bytecode.hbs'; | ||
import { mockVersions } from '../../../test/utils/mockVersions'; | ||
|
||
import { renderBytecodeTemplate } from './bytecode'; | ||
|
||
describe('templates/contract/bytecode', () => { | ||
test('should render bytecode template', () => { | ||
// mocking | ||
const { restore } = mockVersions(); | ||
|
||
// executing | ||
const project = getProjectResources(ForcProjectsEnum.MINIMAL); | ||
|
||
const rendered = renderBytecodeTemplate({ | ||
hexlifiedBytecode: project.binHexlified, | ||
}); | ||
|
||
// validating | ||
restore(); | ||
|
||
expect(rendered).toEqual(bytecodeTemplte); | ||
}); | ||
}); |
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,16 @@ | ||
import type { BytesLike } from '@ethersproject/bytes'; | ||
|
||
import { renderHbsTemplate } from '../renderHbsTemplate'; | ||
|
||
import bytecodeTemplate from './bytecode.hbs'; | ||
|
||
export function renderBytecodeTemplate(params: { hexlifiedBytecode: BytesLike }) { | ||
const text = renderHbsTemplate({ | ||
template: bytecodeTemplate, | ||
data: { | ||
hexlifiedBytecode: params.hexlifiedBytecode, | ||
}, | ||
}); | ||
|
||
return text; | ||
} |
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
12 changes: 12 additions & 0 deletions
12
packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs
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,12 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
/* | ||
Fuels version: 11.11.11 | ||
Forc version: 22.22.22 | ||
Fuel-Core version: 33.33.33 | ||
*/ | ||
|
||
export default '0x900000044700000000000000000000445dfcc00110fff3005d4060495d47f000134904407348000c72f0007b36f000005d44604a504110005041101024040000470000000000000055b7ae10' |
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