-
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.
Merge branch 'master' into st/fix/witness-entry-for-predicates
- Loading branch information
Showing
41 changed files
with
1,185 additions
and
248 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,2 @@ | ||
--- | ||
--- |
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 | ||
--- | ||
|
||
feat: support `Result<T, E>` type in 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
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,2 @@ | ||
--- | ||
--- |
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,40 @@ | ||
import { | ||
AbiTypegenProjectsEnum, | ||
getTypegenForcProject, | ||
} from '../../../test/fixtures/forc-projects/index'; | ||
import type { IRawAbiTypeRoot } from '../../index'; | ||
import { parseTypes } from '../../utils/parseTypes'; | ||
|
||
import { EnumType } from './EnumType'; | ||
import { ResultType } from './ResultType'; | ||
|
||
/** | ||
* @group node | ||
*/ | ||
describe('ResultType.ts', () => { | ||
/* | ||
Test helpers | ||
*/ | ||
function getResultType() { | ||
const project = getTypegenForcProject(AbiTypegenProjectsEnum.FULL); | ||
const rawTypes = project.abiContents.types as IRawAbiTypeRoot[]; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return parseTypes({ rawAbiTypes: [rawTypes.find((t) => t.type === 'enum Result')!] })[0]; | ||
} | ||
|
||
test('should properly evaluate type suitability', () => { | ||
const suitableForResult = ResultType.isSuitableFor({ type: ResultType.swayType }); | ||
const suitableForEnum = ResultType.isSuitableFor({ type: EnumType.swayType }); | ||
|
||
expect(suitableForResult).toEqual(true); | ||
expect(suitableForEnum).toEqual(false); | ||
}); | ||
|
||
test('should properly parse type attributes', () => { | ||
const type = getResultType(); | ||
|
||
expect(type.attributes.inputLabel).toEqual('Result'); | ||
expect(type.attributes.outputLabel).toEqual('Result'); | ||
expect(type.requiredFuelsMembersImports).toStrictEqual([]); | ||
}); | ||
}); |
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,23 @@ | ||
import type { IType } from '../../types/interfaces/IType'; | ||
|
||
import { AType } from './AType'; | ||
|
||
export class ResultType extends AType implements IType { | ||
public static swayType = 'enum Result'; | ||
|
||
public name = 'result'; | ||
|
||
static MATCH_REGEX: RegExp = /^enum Result$/m; | ||
|
||
static isSuitableFor(params: { type: string }) { | ||
return ResultType.MATCH_REGEX.test(params.type); | ||
} | ||
|
||
public parseComponentsAttributes(_params: { types: IType[] }) { | ||
this.attributes = { | ||
inputLabel: `Result`, | ||
outputLabel: `Result`, | ||
}; | ||
return this.attributes; | ||
} | ||
} |
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
Oops, something went wrong.