This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
335 additions
and
504 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
3 changes: 0 additions & 3 deletions
3
packages/abi-gen/templates/TypeScript/partials/call.handlebars
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars
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,34 @@ | ||
/** | ||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before | ||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used | ||
* to create a 0x transaction (see protocol spec for more details). | ||
{{> params_docstring inputs=inputs docstrings=devdoc.params}} | ||
*/ | ||
getABIEncodedTransactionData( | ||
{{> typed_params inputs=inputs}} | ||
): string { | ||
{{#each inputs}} | ||
{{#assertionType name type}}{{/assertionType}} | ||
{{/each}} | ||
const self = this as any as {{contractName}}Contract; | ||
const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); | ||
return abiEncodedTransactionData; | ||
}, | ||
getABIDecodedTransactionData( | ||
callData: string | ||
): ({{> return_type inputs=inputs ~}}) { | ||
const self = this as any as {{contractName}}Contract; | ||
const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); | ||
// tslint:disable boolean-naming | ||
const abiDecodedCallData = abiEncoder.strictDecode<{{> return_type inputs=inputs}}>(callData); | ||
return abiDecodedCallData; | ||
}, | ||
getABIDecodedReturnData( | ||
returnData: string | ||
): ({{> return_type outputs=outputs ~}}) { | ||
const self = this as any as {{contractName}}Contract; | ||
const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); | ||
// tslint:disable boolean-naming | ||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData); | ||
return abiDecodedReturnData; | ||
}, |
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
37 changes: 37 additions & 0 deletions
37
packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars
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,37 @@ | ||
/** | ||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an | ||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas | ||
* since they don't modify state. | ||
{{> params_docstring inputs=inputs docstrings=devdoc.params}} | ||
{{#if devdoc.return}} | ||
* @returns {{devdoc.return}} | ||
{{/if}} | ||
*/ | ||
async callAsync( | ||
{{> typed_params inputs=inputs}} | ||
callData: Partial<CallData> = {}, | ||
defaultBlock?: BlockParam, | ||
): Promise<{{> return_type outputs=outputs}}> { | ||
{{#each inputs}} | ||
{{#assertionType name type}}{{/assertionType}} | ||
{{/each}} | ||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ | ||
schemas.addressSchema, | ||
schemas.numberSchema, | ||
schemas.jsNumber, | ||
]); | ||
if (defaultBlock !== undefined) { | ||
assert.isBlockParam('defaultBlock', defaultBlock); | ||
} | ||
const self = this as any as {{contractName}}Contract; | ||
const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); | ||
const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); | ||
|
||
const rawCallResult = await self.evmExecAsync(encodedDataBytes); | ||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); | ||
const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); | ||
// tslint:disable boolean-naming | ||
const result = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(rawCallResult); | ||
// tslint:enable boolean-naming | ||
return result; | ||
}, |
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.