From 5dbb752c9187518933198223e4b7defc9dd75343 Mon Sep 17 00:00:00 2001 From: Bobby Lat Date: Thu, 12 Dec 2024 18:37:49 +0800 Subject: [PATCH] feat: implement arc4.methodSelector function --- packages/algo-ts/src/arc4/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/algo-ts/src/arc4/index.ts b/packages/algo-ts/src/arc4/index.ts index ca63b31f..274dcff5 100644 --- a/packages/algo-ts/src/arc4/index.ts +++ b/packages/algo-ts/src/arc4/index.ts @@ -1,7 +1,8 @@ +import { op } from '..' import { BaseContract } from '../base-contract' import { ctxMgr } from '../execution-context' -import { NoImplementation } from '../impl/errors' -import { bytes, Uint64 } from '../primitives' +import { encodingUtil } from '../internal' +import { Bytes, bytes, Uint64 } from '../primitives' import { DeliberateAny } from '../typescript-helpers' export * from './encoded-types' @@ -91,5 +92,5 @@ export function baremethod(config?: BareMethodConfig * @returns The ARC4 method selector. Eg. `02BECE11` */ export function methodSelector(methodSignature: string): bytes { - throw new NoImplementation() + return op.sha512_256(Bytes(encodingUtil.utf8ToUint8Array(methodSignature))).slice(0, 4) }