Skip to content

Commit

Permalink
feat: implement arc4.methodSelector function
Browse files Browse the repository at this point in the history
  • Loading branch information
boblat committed Dec 17, 2024
1 parent 3e1aa5c commit 5dbb752
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/algo-ts/src/arc4/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -91,5 +92,5 @@ export function baremethod<TContract extends Contract>(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)
}

0 comments on commit 5dbb752

Please sign in to comment.