-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add JS types for ABI and input maps (#3023)
Co-authored-by: kevaundray <[email protected]>
- Loading branch information
1 parent
9fb7183
commit 599e7a1
Showing
15 changed files
with
147 additions
and
69 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
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
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { expect } from 'chai'; | ||
import { abiEncode, abiDecode, WitnessMap } from '@noir-lang/noirc_abi'; | ||
import { abiEncode, abiDecode, WitnessMap, Field } from '@noir-lang/noirc_abi'; | ||
import { DecodedInputs } from '../types'; | ||
|
||
it('recovers original inputs when abi encoding and decoding', async () => { | ||
const { abi, inputs } = await import('../shared/abi_encode'); | ||
|
||
const initial_witness: WitnessMap = abiEncode(abi, inputs, null); | ||
const initial_witness: WitnessMap = abiEncode(abi, inputs); | ||
const decoded_inputs: DecodedInputs = abiDecode(abi, initial_witness); | ||
|
||
expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); | ||
expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal(BigInt(inputs.bar[0])); | ||
expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal(BigInt(inputs.bar[1])); | ||
const foo: Field = inputs.foo as Field; | ||
const bar: Field[] = inputs.bar as Field[]; | ||
expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(foo)); | ||
expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal(BigInt(bar[0])); | ||
expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal(BigInt(bar[1])); | ||
expect(decoded_inputs.return_value).to.be.null; | ||
}); |
Oops, something went wrong.