forked from aragon/osx-plugin-template-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementes decoding findInterfaces function
Signed-off-by: emmdim <[email protected]>
- Loading branch information
Showing
4 changed files
with
27 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
import { InterfaceParams, getFunctionFragment } from "@aragon/sdk-client-common"; | ||
import { OffchainVotingClientCore } from "../core"; | ||
import { IOffchainVotingClientDecoding } from "../interfaces"; | ||
import { AVAILABLE_FUNCTION_SIGNATURES } from "../constants"; | ||
import { bytesToHex } from "@aragon/sdk-common"; | ||
|
||
export class OffchainVotingClientDecoding extends OffchainVotingClientCore | ||
implements IOffchainVotingClientDecoding { | ||
// add your action decoders here | ||
/** | ||
* Returns the decoded function info given the encoded data of an action | ||
* | ||
* @param {Uint8Array} data | ||
* @return {*} {(InterfaceParams | null)} | ||
* @memberof OffchainVotingClientDecoding | ||
*/ | ||
public findInterface(data: Uint8Array): InterfaceParams | null { | ||
try { | ||
const func = getFunctionFragment(data, AVAILABLE_FUNCTION_SIGNATURES); | ||
return { | ||
id: func.format("minimal"), | ||
functionName: func.name, | ||
hash: bytesToHex(data).substring(0, 10), | ||
}; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
} |
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