-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: organized workspace alphabetically * feat: added void contract * feat: added void test * chore: added `VOID_TYPE` * feat: converted `void` tests to echo based, added NativeEnums * feat: added `VoidCoder` * chore: changeset * chore: simplify the `EnumCoder::isNativeEnum` check * chore: update void test * feat: implemented EmptyType for typegen, matched to `undefined` * feat: added e2e tests around the void arguments * chore: fixing tests * feat: implemented `getMandatoryInputs` * feat: added optional argument parsing * chore: added Option ABI type testing * chore: added forcBuildFlag to test * feat: implemented option function parameters * chore: removed optional arguments from tests * chore: made void return type for EmptyType * chore: added missing test group * deps: added `ramda` to `abi-coder` * chore: implemented optional parameters for coder * chore: fixing lock file * chore: lint * chore: renamed `findNonEmptyInputs` to `findNonVoidInputs` * chore: iterate over all inputs for `decodeArguments` * chore: removed void check for `decodeOutput` * chore: added test for optional option * chore: housekeeping * Add option tests * Linting * chore: add script test with options (WIP) * chore: added script options test * chore: renamed `getMandatoryInputs` -> `getFunctionInputs` * chore: fixed lockfile * chore: updated changeset * chore: fix lock file * reinstall ramda * Removed dependency on ramda * Added `@group browser` tests * chore: implemented optimizations for `getFunctionInputs` * chore: implemented `padValuesWithUndefined` * chore: added missing test groupings --------- Co-authored-by: Chad Nehemiah <[email protected]>
- Loading branch information
1 parent
9156c02
commit 9c07b00
Showing
35 changed files
with
825 additions
and
211 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,6 @@ | ||
--- | ||
"@fuel-ts/abi-coder": patch | ||
"@fuel-ts/abi-typegen": patch | ||
--- | ||
|
||
feat!: improve `()` and `Option<T>` type handling |
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,38 @@ | ||
import { VoidCoder } from './VoidCoder'; | ||
|
||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
describe('VoidCoder', () => { | ||
it('should have properties', () => { | ||
const coder = new VoidCoder(); | ||
expect(coder.name).toEqual('void'); | ||
expect(coder.type).toEqual('()'); | ||
expect(coder.encodedLength).toEqual(0); | ||
}); | ||
|
||
describe('encode', () => { | ||
it('should return an empty Uint8Array', () => { | ||
const input = undefined; | ||
const expected = new Uint8Array([]); | ||
|
||
const coder = new VoidCoder(); | ||
const value = coder.encode(input); | ||
expect(value).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('decode', () => { | ||
it('should return an undefined result', () => { | ||
const input = new Uint8Array([]); | ||
const expected = undefined; | ||
const expectedOffset = 0; | ||
|
||
const coder = new VoidCoder(); | ||
const [value, offset] = coder.decode(input, 0); | ||
expect(value).toEqual(expected); | ||
expect(offset).toEqual(expectedOffset); | ||
}); | ||
}); | ||
}); |
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,17 @@ | ||
import { VOID_TYPE } from '../../utils/constants'; | ||
|
||
import { Coder } from './AbstractCoder'; | ||
|
||
export class VoidCoder extends Coder<undefined, undefined> { | ||
constructor() { | ||
super('void', VOID_TYPE, 0); | ||
} | ||
|
||
encode(_value: undefined): Uint8Array { | ||
return new Uint8Array([]); | ||
} | ||
|
||
decode(_data: Uint8Array, offset: number): [undefined, number] { | ||
return [undefined, offset]; | ||
} | ||
} |
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.