Skip to content

Commit

Permalink
ts-web/rt: restore async callformat encode/decode
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Oct 17, 2024
1 parent faa86fd commit dd234c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client-sdk/ts-web/rt/src/callformat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export interface MetaEncryptedX25519DeoxysII {
* encodeCallWithNonceAndKeys encodes a call based on its configured call format.
* It returns the encoded call and any metadata needed to successfully decode the result.
*/
export function encodeCallWithNonceAndKeys(
export async function encodeCallWithNonceAndKeys(
nonce: Uint8Array,
sk: Uint8Array,
pk: Uint8Array,
call: types.Call,
format: types.CallFormat,
config?: EncodeConfig,
): [types.Call, unknown] {
): Promise<[types.Call, unknown]> {
switch (format) {
case transaction.CALLFORMAT_PLAIN:
return [call, undefined];
Expand Down Expand Up @@ -80,15 +80,15 @@ export function encodeCallWithNonceAndKeys(
* encodeCall randomly generates nonce and keyPair and then call encodeCallWithNonceAndKeys
* It returns the encoded call and any metadata needed to successfully decode the result.
*/
export function encodeCall(
export async function encodeCall(
call: types.Call,
format: types.CallFormat,
config?: EncodeConfig,
): [types.Call, unknown] {
): Promise<[types.Call, unknown]> {
const nonce = new Uint8Array(deoxysii.NonceSize);
crypto.getRandomValues(nonce);
const keyPair = nacl.box.keyPair();
return encodeCallWithNonceAndKeys(
return await encodeCallWithNonceAndKeys(
nonce,
keyPair.secretKey,
keyPair.publicKey,
Expand All @@ -101,11 +101,11 @@ export function encodeCall(
/**
* decodeResult performs result decoding based on the specified call format metadata.
*/
export function decodeResult(
export async function decodeResult(
result: types.CallResult,
format: types.CallFormat,
meta?: MetaEncryptedX25519DeoxysII,
): types.CallResult {
): Promise<types.CallResult> {
switch (format) {
case transaction.CALLFORMAT_PLAIN:
// In case of plain-text data format, we simply pass on the result unchanged.
Expand Down

0 comments on commit dd234c9

Please sign in to comment.