From dd800eb248385a723aa6c1685f4e64d2e68ab88f Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 22 Nov 2022 17:47:53 +0800 Subject: [PATCH 01/24] cherry pick from arraybuffer branch --- builder/builder.c | 2172 ++++++++++++++++++++++++--------------------- src/api.ts | 182 ++-- 2 files changed, 1227 insertions(+), 1127 deletions(-) diff --git a/builder/builder.c b/builder/builder.c index 0e34df0b5..cecd2dd52 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -1,1036 +1,1136 @@ -#include -#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/quickjs-libc-min.h" -#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/libbf.h" -#include "code.h" - -static JSContext *JS_NewCustomContext(JSRuntime *rt) -{ - JSContext *ctx = JS_NewContextRaw(rt); - if (!ctx) - return NULL; - JS_AddIntrinsicBaseObjects(ctx); - JS_AddIntrinsicDate(ctx); - JS_AddIntrinsicEval(ctx); - JS_AddIntrinsicStringNormalize(ctx); - JS_AddIntrinsicRegExp(ctx); - JS_AddIntrinsicJSON(ctx); - JS_AddIntrinsicProxy(ctx); - JS_AddIntrinsicMapSet(ctx); - JS_AddIntrinsicTypedArrays(ctx); - JS_AddIntrinsicPromise(ctx); - JS_AddIntrinsicBigInt(ctx); - return ctx; -} - -#define DEFINE_NEAR_METHOD(name) \ - void name () __attribute__((export_name(#name))) {\ - JSRuntime *rt;\ - JSContext *ctx;\ - JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ - const char *error_message_c, *error_stack_c;\ - char *error_c;\ - size_t msg_len, stack_len;\ - rt = JS_NewRuntime();\ - ctx = JS_NewCustomContext(rt);\ - js_add_near_host_functions(ctx);\ - mod_obj = js_load_module_binary(ctx, code, code_size);\ - fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ - result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ - if (JS_IsException(result)) {\ - error = JS_GetException(ctx);\ - error_message = JS_GetPropertyStr(ctx, error, "message");\ - error_stack = JS_GetPropertyStr(ctx, error, "stack");\ - error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ - error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ - error_c = malloc(msg_len+1+stack_len);\ - strncpy(error_c, error_message_c, msg_len);\ - error_c[msg_len] = '\n';\ - strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ - panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ - }\ - js_std_loop(ctx);\ - } - -// ############# -// # Registers # -// ############# -extern void read_register(uint64_t register_id, uint64_t ptr); -extern uint64_t register_len(uint64_t register_id); -extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); -// ############### -// # Context API # -// ############### -extern void current_account_id(uint64_t register_id); -extern void signer_account_id(uint64_t register_id); -extern void signer_account_pk(uint64_t register_id); -extern void predecessor_account_id(uint64_t register_id); -extern void input(uint64_t register_id); -extern uint64_t block_index(); -extern uint64_t block_timestamp(); -extern uint64_t epoch_height(); -extern uint64_t storage_usage(); -// ################# -// # Economics API # -// ################# -extern void account_balance(uint64_t balance_ptr); -extern void account_locked_balance(uint64_t balance_ptr); -extern void attached_deposit(uint64_t balance_ptr); -extern uint64_t prepaid_gas(); -extern uint64_t used_gas(); -// ############ -// # Math API # -// ############ -extern void random_seed(uint64_t register_id); -extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); -// ##################### -// # Miscellaneous API # -// ##################### -extern void value_return(uint64_t value_len, uint64_t value_ptr); -extern void panic(void); -extern void panic_utf8(uint64_t len, uint64_t ptr); -extern void log_utf8(uint64_t len, uint64_t ptr); -extern void log_utf16(uint64_t len, uint64_t ptr); -// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade -// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. -// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); -// ################ -// # Promises API # -// ################ -extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); -extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); -extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); -// ####################### -// # Promise API actions # -// ####################### -extern void promise_batch_action_create_account(uint64_t promise_index); -extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); -extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); -extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); -extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); -extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); -extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); -// ####################### -// # Promise API results # -// ####################### -extern uint64_t promise_results_count(void); -extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); -extern void promise_return(uint64_t promise_idx); -// ############### -// # Storage API # -// ############### -extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); -// ################# -// # Validator API # -// ################# -extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); -extern void validator_total_stake(uint64_t stake_ptr); -// ############# -// # Alt BN128 # -// ############# -#ifdef NIGHTLY -extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); -#endif - -static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - char *data; - uint64_t data_len; - JSValue ret; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_len = register_len(register_id); - if (data_len != UINT64_MAX) { - data = malloc(data_len); - read_register(register_id, (uint64_t)data); - ret = JS_NewStringLenRaw(ctx, data, data_len); - free(data); - return ret; - } else { - return JS_UNDEFINED; - } -} - -static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id, len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - len = register_len(register_id); - return JS_NewBigUint64(ctx, len); -} - -static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[1]); - - write_register(register_id, data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - current_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_pk(register_id); - return JS_UNDEFINED; -} - -static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - predecessor_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - input(register_id); - return JS_UNDEFINED; -} - -static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_index(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_timestamp(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = epoch_height(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = storage_usage(); - return JS_NewBigUint64(ctx, value); -} - -// ptr[0] ptr[1] is little-endian u128. -static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { - JSValue value; - bf_t* bn; - bf_t b; - - value = JS_NewBigInt(ctx); - bn = JS_GetBigInt(value); - // from ptr[] to bn - // high 64 bits - bf_set_ui(bn, ptr[1]); - bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); - // low 64 bits - bf_init(bn->ctx, &b); - bf_set_ui(&b, ptr[0]); - bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); - bf_delete(&b); - - return value; -} - -static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - bf_t* a; - bf_t q, r, b, one, u128max; - a = JS_GetBigInt(val); - bf_init(a->ctx, &u128max); - bf_set_ui(&u128max, 1); - bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); - if (bf_cmp_le(&u128max, a)) { - return 1; - } - bf_init(a->ctx, &q); - bf_init(a->ctx, &r); - bf_init(a->ctx, &b); - bf_init(a->ctx, &one); - bf_set_ui(&b, UINT64_MAX); - bf_set_ui(&one, 1); - bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); - bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); - - bf_get_uint64(ptr, &r); - bf_get_uint64(ptr+1, &q); - return 0; -} - -static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_ToUint64Ext(ctx, ptr, val) < 0) { - return 1; - } - ptr[1] = 0; - return 0; -} - -static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_IsBigInt(ctx, val)) - return quickjs_bigint_to_u128(ctx, val, ptr); - else { - return quickjs_int_to_u128(ctx, val, ptr); - } -} - -static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_locked_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - attached_deposit((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = prepaid_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = used_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - random_seed(register_id); - return JS_UNDEFINED; -} - -static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - sha256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - keccak256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - keccak512(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - ripemd160(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t malleability_flag, v, register_id, result; - const char *hash_ptr, *sig_ptr; - size_t hash_len, sign_len; - - hash_ptr = JS_ToCStringLenRaw(ctx, &hash_len, argv[0]); - sig_ptr = JS_ToCStringLenRaw(ctx, &sign_len, argv[1]); - if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); - } - if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); - return JS_NewBigUint64(ctx, result); -} - -static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *value_ptr; - size_t value_len; - - value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[0]); - value_return(value_len, (uint64_t)value_ptr); - return JS_UNDEFINED; -} - -static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - if (argc == 1) { - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - panic_utf8(data_len, (uint64_t)data_ptr); - } else { - panic(); - } - return JS_UNDEFINED; -} - -static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - - panic_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - log_utf16(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr, *method_name_ptr, *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr, *method_name_ptr, *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[3]); - if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx_ptr[argc], ret; - - for(int i = 0; i < argc; i++) { - if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); - } - } - ret = promise_and((uint64_t)promise_idx_ptr, argc); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - promise_batch_action_create_account(promise_index); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *code_ptr; - size_t code_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - code_ptr = JS_ToCStringLenRaw(ctx, &code_len, argv[1]); - promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr, *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; // amount is u128 - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; - const char *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[2]); - - promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *public_key_ptr; - size_t public_key_len; - uint64_t nonce; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *public_key_ptr, *receiver_id_ptr, *method_names_ptr; - size_t public_key_len, receiver_id_len, method_names_len; - uint64_t nonce, allowance_ptr[2]; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); - } - receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); - method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); - - promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); - promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr, *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - uint64_t weight; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); - } - promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *beneficiary_id_ptr; - size_t beneficiary_id_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); - promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = promise_results_count(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t result_idx, register_id; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = promise_result(result_idx, register_id); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx; - if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); - } - promise_return(promise_idx); - - return JS_UNDEFINED; -} - -static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *key_ptr, *value_ptr; - size_t key_len, value_len; - uint64_t register_id, ret; - - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); - value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[1]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_read(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *key_ptr; - size_t key_len; - uint64_t ret; - - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); - ret = storage_has_key(key_len, (uint64_t)key_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t stake_ptr[2]; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); - - return u128_to_quickjs(ctx, stake_ptr); -} - -static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t stake_ptr[2]; - - validator_total_stake((uint64_t)stake_ptr); - return u128_to_quickjs(ctx, stake_ptr); -} - -#ifdef NIGHTLY -static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - uint64_t ret; - - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - - ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); - return JS_NewBigUint64(ctx, ret); -} -#endif - -static void js_add_near_host_functions(JSContext* ctx) { - JSValue global_obj, env; - - global_obj = JS_GetGlobalObject(ctx); - env = JS_NewObject(ctx); - - JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); - JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); - JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); - JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); - JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); - JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); - JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); - JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); - JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); - JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); - JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); - JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); - JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); - JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); - JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); - JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); - JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); - JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); - JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); - JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); - JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); - JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); - JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); - JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); - JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); - JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_utf8", 1)); - JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); - JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); - JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); - JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); - JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); - JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); - JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); - JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); - JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); - JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); - JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); - JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); - JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); - #ifdef NIGHTLY - // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet -// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); - #endif - - JS_SetPropertyStr(ctx, global_obj, "env", env); -} - -JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, - int argc, JSValueConst *argv); - -void _start() {} - -#include "methods.h" +#include +#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" +#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" +#include "code.h" + +static JSContext *JS_NewCustomContext(JSRuntime *rt) +{ + JSContext *ctx = JS_NewContextRaw(rt); + if (!ctx) + return NULL; + JS_AddIntrinsicBaseObjects(ctx); + JS_AddIntrinsicDate(ctx); + JS_AddIntrinsicEval(ctx); + JS_AddIntrinsicStringNormalize(ctx); + JS_AddIntrinsicRegExp(ctx); + JS_AddIntrinsicJSON(ctx); + JS_AddIntrinsicProxy(ctx); + JS_AddIntrinsicMapSet(ctx); + JS_AddIntrinsicTypedArrays(ctx); + JS_AddIntrinsicPromise(ctx); + JS_AddIntrinsicBigInt(ctx); + return ctx; +} + +#define DEFINE_NEAR_METHOD(name) \ + void name () __attribute__((export_name(#name))) {\ + JSRuntime *rt;\ + JSContext *ctx;\ + JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ + const char *error_message_c, *error_stack_c;\ + char *error_c;\ + size_t msg_len, stack_len;\ + rt = JS_NewRuntime();\ + ctx = JS_NewCustomContext(rt);\ + js_add_near_host_functions(ctx);\ + mod_obj = js_load_module_binary(ctx, code, code_size);\ + fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ + result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ + if (JS_IsException(result)) {\ + error = JS_GetException(ctx);\ + error_message = JS_GetPropertyStr(ctx, error, "message");\ + error_stack = JS_GetPropertyStr(ctx, error, "stack");\ + error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ + error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ + error_c = malloc(msg_len+1+stack_len);\ + strncpy(error_c, error_message_c, msg_len);\ + error_c[msg_len] = '\n';\ + strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ + panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ + }\ + js_std_loop(ctx);\ + } + +// ############# +// # Registers # +// ############# +extern void read_register(uint64_t register_id, uint64_t ptr); +extern uint64_t register_len(uint64_t register_id); +extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); +// ############### +// # Context API # +// ############### +extern void current_account_id(uint64_t register_id); +extern void signer_account_id(uint64_t register_id); +extern void signer_account_pk(uint64_t register_id); +extern void predecessor_account_id(uint64_t register_id); +extern void input(uint64_t register_id); +extern uint64_t block_index(); +extern uint64_t block_timestamp(); +extern uint64_t epoch_height(); +extern uint64_t storage_usage(); +// ################# +// # Economics API # +// ################# +extern void account_balance(uint64_t balance_ptr); +extern void account_locked_balance(uint64_t balance_ptr); +extern void attached_deposit(uint64_t balance_ptr); +extern uint64_t prepaid_gas(); +extern uint64_t used_gas(); +// ############ +// # Math API # +// ############ +extern void random_seed(uint64_t register_id); +extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); +// ##################### +// # Miscellaneous API # +// ##################### +extern void value_return(uint64_t value_len, uint64_t value_ptr); +extern void panic(void); +extern void panic_utf8(uint64_t len, uint64_t ptr); +extern void log_utf8(uint64_t len, uint64_t ptr); +extern void log_utf16(uint64_t len, uint64_t ptr); +// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade +// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. +// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); +// ################ +// # Promises API # +// ################ +extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); +extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); +extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); +// ####################### +// # Promise API actions # +// ####################### +extern void promise_batch_action_create_account(uint64_t promise_index); +extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); +extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); +extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); +extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); +extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); +extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); +// ####################### +// # Promise API results # +// ####################### +extern uint64_t promise_results_count(void); +extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); +extern void promise_return(uint64_t promise_idx); +// ############### +// # Storage API # +// ############### +extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); +// ################# +// # Validator API # +// ################# +extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); +extern void validator_total_stake(uint64_t stake_ptr); +// ############# +// # Alt BN128 # +// ############# +#ifdef NIGHTLY +extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); +#endif + +static uint8_t* JS_Uint8Array_to_C(JSContext *ctx, JSValue array, size_t *len) { + uint8_t *ptr; + JSValue buffer; + size_t pbyte_offset, psize, pbytes_per_element = 0; + + buffer = JS_GetTypedArrayBuffer(ctx, array, &pbyte_offset, len, &pbytes_per_element); + if (JS_IsException(buffer) || pbytes_per_element != 1) { + return NULL; + } + ptr = JS_GetArrayBuffer(ctx, &psize, buffer); + if (ptr == NULL) { + return NULL; + } + return ptr + pbyte_offset; +} + +static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data; + uint64_t data_len; + JSValue arraybuffer, ret; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_len = register_len(register_id); + if (data_len != UINT64_MAX) { + data = malloc(data_len); + read_register(register_id, (uint64_t)data); + arraybuffer = JS_NewArrayBuffer(ctx, data, (size_t)data_len, NULL, NULL, TRUE); + return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); + } else { + return JS_UNDEFINED; + } +} + +static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id, len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + len = register_len(register_id); + return JS_NewBigUint64(ctx, len); +} + +static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_ptr = JS_Uint8Array_to_C(ctx, argv[1], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + + write_register(register_id, data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + current_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_pk(register_id); + return JS_UNDEFINED; +} + +static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + predecessor_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + input(register_id); + return JS_UNDEFINED; +} + +static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_index(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_timestamp(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = epoch_height(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = storage_usage(); + return JS_NewBigUint64(ctx, value); +} + +// ptr[0] ptr[1] is little-endian u128. +static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { + JSValue value; + bf_t* bn; + bf_t b; + + value = JS_NewBigInt(ctx); + bn = JS_GetBigInt(value); + // from ptr[] to bn + // high 64 bits + bf_set_ui(bn, ptr[1]); + bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); + // low 64 bits + bf_init(bn->ctx, &b); + bf_set_ui(&b, ptr[0]); + bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); + bf_delete(&b); + + return value; +} + +static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + bf_t* a; + bf_t q, r, b, one, u128max; + a = JS_GetBigInt(val); + bf_init(a->ctx, &u128max); + bf_set_ui(&u128max, 1); + bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); + if (bf_cmp_le(&u128max, a)) { + return 1; + } + bf_init(a->ctx, &q); + bf_init(a->ctx, &r); + bf_init(a->ctx, &b); + bf_init(a->ctx, &one); + bf_set_ui(&b, UINT64_MAX); + bf_set_ui(&one, 1); + bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); + bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); + + bf_get_uint64(ptr, &r); + bf_get_uint64(ptr+1, &q); + return 0; +} + +static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_ToUint64Ext(ctx, ptr, val) < 0) { + return 1; + } + ptr[1] = 0; + return 0; +} + +static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_IsBigInt(ctx, val)) + return quickjs_bigint_to_u128(ctx, val, ptr); + else { + return quickjs_int_to_u128(ctx, val, ptr); + } +} + +static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_locked_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + attached_deposit((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = prepaid_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = used_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + random_seed(register_id); + return JS_UNDEFINED; +} + +static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + sha256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + keccak256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + keccak512(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + ripemd160(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t malleability_flag, v, register_id, result; + uint8_t *hash_ptr, *sig_ptr; + size_t hash_len, sign_len; + + hash_ptr = JS_Uint8Array_to_C(ctx, argv[0], &hash_len); + if (hash_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for hash"); + } + sig_ptr = JS_Uint8Array_to_C(ctx, argv[1], &sign_len); + if (sig_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for sig"); + } + if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); + } + if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); + return JS_NewBigUint64(ctx, result); +} + +static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *value_ptr; + size_t value_len; + + value_ptr = JS_Uint8Array_to_C(ctx, argv[0], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } + value_return(value_len, (uint64_t)(value_ptr)); + return JS_UNDEFINED; +} + +static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + if (argc == 1) { + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + panic_utf8(data_len, (uint64_t)data_ptr); + } else { + panic(); + } + return JS_UNDEFINED; +} + +static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + panic_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + log_utf16(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[3], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx_ptr[argc], ret; + + for(int i = 0; i < argc; i++) { + if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); + } + } + ret = promise_and((uint64_t)promise_idx_ptr, argc); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + promise_batch_action_create_account(promise_index); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *code_ptr; + size_t code_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + code_ptr = JS_Uint8Array_to_C(ctx, argv[1], &code_len); + if (code_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for code"); + } + promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr; + uint8_t *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; // amount is u128 + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; + uint8_t *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[2], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + + promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *public_key_ptr; + size_t public_key_len; + uint64_t nonce; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *receiver_id_ptr, *method_names_ptr; + uint8_t *public_key_ptr; + size_t public_key_len, receiver_id_len, method_names_len; + uint64_t nonce, allowance_ptr[2]; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); + } + receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); + method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); + + promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr, *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + uint64_t weight; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); + } + promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *beneficiary_id_ptr; + size_t beneficiary_id_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); + promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = promise_results_count(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t result_idx, register_id; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = promise_result(result_idx, register_id); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx; + if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); + } + promise_return(promise_idx); + + return JS_UNDEFINED; +} + +static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr, *value_ptr; + size_t key_len, value_len; + uint64_t register_id, ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + value_ptr = JS_Uint8Array_to_C(ctx, argv[1], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_read(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + ret = storage_has_key(key_len, (uint64_t)key_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t stake_ptr[2]; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); + + return u128_to_quickjs(ctx, stake_ptr); +} + +static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t stake_ptr[2]; + + validator_total_stake((uint64_t)stake_ptr); + return u128_to_quickjs(ctx, stake_ptr); +} + +#ifdef NIGHTLY +static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + uint64_t ret; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); + return JS_NewBigUint64(ctx, ret); +} +#endif + +static void js_add_near_host_functions(JSContext* ctx) { + JSValue global_obj, env; + + global_obj = JS_GetGlobalObject(ctx); + env = JS_NewObject(ctx); + + JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); + JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); + JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); + JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); + JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); + JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); + JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); + JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); + JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); + JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); + JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); + JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); + JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); + JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); + JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); + JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); + JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); + JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); + JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); + JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); + JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); + JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); + JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); + JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); + JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); + JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_utf8", 1)); + JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); + JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); + JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); + JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); + JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); + JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); + JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); + JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); + JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); + JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); + JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); + JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); + JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); + #ifdef NIGHTLY + // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet +// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); + #endif + + JS_SetPropertyStr(ctx, global_obj, "env", env); +} + +JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, + int argc, JSValueConst *argv); + +void _start() {} + +#include "methods.h" diff --git a/src/api.ts b/src/api.ts index 131b43a7e..3493f1059 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,4 +1,4 @@ -import { assert, Bytes, NearAmount, PromiseIndex, Register } from "./utils"; +import { assert, NearAmount, PromiseIndex, Register, u8ArrayToLatin1 } from "./utils"; import { GasWeight, PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; @@ -7,21 +7,21 @@ const EVICTED_REGISTER = U64_MAX - 1n; // Interface available in QuickJS interface Env { // Panic - panic_utf8(message: Bytes): never; + panic_utf8(message: Uint8Array): never; // Logging - log(message: Bytes): void; - log_utf8(message: Bytes): void; - log_utf16(message: Bytes): void; + log(message: string): void; + log_utf8(message: Uint8Array): void; + log_utf16(message: Uint8Array): void; // Read from register - read_register(register: Register): string; + read_register(register: Register): Uint8Array; // Storage - storage_read(key: Bytes, register: Register): bigint; - storage_has_key(key: Bytes): bigint; - storage_write(key: Bytes, value: Bytes, register: Register): bigint; - storage_remove(key: Bytes, register: Register): bigint; + storage_read(key: Uint8Array, register: Register): bigint; + storage_has_key(key: Uint8Array): bigint; + storage_write(key: Uint8Array, value: Uint8Array, register: Register): bigint; + storage_remove(key: Uint8Array, register: Register): bigint; storage_usage(): bigint; // Caller methods @@ -35,7 +35,7 @@ interface Env { account_balance(): bigint; account_locked_balance(): bigint; current_account_id(register: Register): void; - validator_stake(accountId: Bytes): bigint; + validator_stake(accountId: string): bigint; validator_total_stake(): bigint; // Blockchain info @@ -48,48 +48,48 @@ interface Env { used_gas(): bigint; // Helper methods and cryptography - value_return(value: Bytes): void; + value_return(value: Uint8Array): void; random_seed(register: Register): void; - sha256(value: Bytes, register: Register): void; - keccak256(value: Bytes, register: Register): void; - keccak512(value: Bytes, register: Register): void; - ripemd160(value: Bytes, register: Register): void; + sha256(value: Uint8Array, register: Register): void; + keccak256(value: Uint8Array, register: Register): void; + keccak512(value: Uint8Array, register: Register): void; + ripemd160(value: Uint8Array, register: Register): void; ecrecover( - hash: Bytes, - sig: Bytes, + hash: Uint8Array, + sig: Uint8Array, v: number, malleabilityFlag: number, register: Register ): bigint; - alt_bn128_g1_multiexp(value: Bytes, register: Register): void; - alt_bn128_g1_sum(value: Bytes, register: Register): void; - alt_bn128_pairing_check(value: Bytes): bigint; + alt_bn128_g1_multiexp(value: Uint8Array, register: Register): void; + alt_bn128_g1_sum(value: Uint8Array, register: Register): void; + alt_bn128_pairing_check(value: Uint8Array): bigint; // Promises promise_create( - accountId: Bytes, - methodName: Bytes, - args: Bytes, + accountId: string, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): bigint; promise_then( promiseIndex: bigint, - accountId: Bytes, - methodName: Bytes, - args: Bytes, + accountId: string, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): bigint; promise_and(...promiseIndexes: bigint[]): bigint; - promise_batch_create(accountId: Bytes): bigint; - promise_batch_then(promiseIndex: bigint, accountId: Bytes): bigint; + promise_batch_create(accountId: string): bigint; + promise_batch_then(promiseIndex: bigint, accountId: string): bigint; promise_batch_action_create_account(promiseIndex: bigint): void; - promise_batch_action_deploy_contract(promiseIndex: bigint, code: Bytes): void; + promise_batch_action_deploy_contract(promiseIndex: bigint, code: Uint8Array): void; promise_batch_action_function_call( promiseIndex: bigint, - methodName: Bytes, - args: Bytes, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): void; @@ -97,30 +97,30 @@ interface Env { promise_batch_action_stake( promiseIndex: bigint, amount: NearAmount, - publicKey: Bytes + publicKey: Uint8Array ): void; promise_batch_action_add_key_with_full_access( promiseIndex: bigint, - publicKey: Bytes, + publicKey: Uint8Array, nonce: number | bigint ): void; promise_batch_action_add_key_with_function_call( promiseIndex: bigint, - publicKey: Bytes, + publicKey: Uint8Array, nonce: number | bigint, allowance: NearAmount, - receiverId: Bytes, - methodNames: Bytes + receiverId: string, + methodNames: string ): void; - promise_batch_action_delete_key(promiseIndex: bigint, publicKey: Bytes): void; + promise_batch_action_delete_key(promiseIndex: bigint, publicKey: Uint8Array): void; promise_batch_action_delete_account( promiseIndex: bigint, - beneficiaryId: Bytes + beneficiaryId: string ): void; promise_batch_action_function_call_weight( promiseIndex: bigint, - methodName: Bytes, - args: Bytes, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount, weight: GasWeight @@ -159,16 +159,16 @@ export function log(...params: unknown[]): void { * Returns the account ID of the account that signed the transaction. * Can only be called in a call or initialize function. */ -export function signerAccountId(): Bytes { +export function signerAccountId(): string { env.signer_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** * Returns the public key of the account that signed the transaction. * Can only be called in a call or initialize function. */ -export function signerAccountPk(): Bytes { +export function signerAccountPk(): Uint8Array { env.signer_account_pk(0); return env.read_register(0); } @@ -177,17 +177,17 @@ export function signerAccountPk(): Bytes { * Returns the account ID of the account that called the function. * Can only be called in a call or initialize function. */ -export function predecessorAccountId(): Bytes { +export function predecessorAccountId(): string { env.predecessor_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** * Returns the account ID of the current contract - the contract that is being executed. */ -export function currentAccountId(): Bytes { +export function currentAccountId(): string { env.current_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** @@ -259,7 +259,7 @@ export function accountLockedBalance(): bigint { * * @param key - The key to read from storage. */ -export function storageRead(key: Bytes): Bytes | null { +export function storageRead(key: Uint8Array): Uint8Array | null { const returnValue = env.storage_read(key, 0); if (returnValue !== 1n) { @@ -274,14 +274,14 @@ export function storageRead(key: Bytes): Bytes | null { * * @param key - The key to check for in storage. */ -export function storageHasKey(key: Bytes): boolean { +export function storageHasKey(key: Uint8Array): boolean { return env.storage_has_key(key) === 1n; } /** * Get the last written or removed value from NEAR storage. */ -export function storageGetEvicted(): Bytes { +export function storageGetEvicted(): Uint8Array { return env.read_register(EVICTED_REGISTER); } @@ -298,7 +298,7 @@ export function storageUsage(): bigint { * @param key - The key under which to store the value. * @param value - The value to store. */ -export function storageWrite(key: Bytes, value: Bytes): boolean { +export function storageWrite(key: Uint8Array, value: Uint8Array): boolean { return env.storage_write(key, value, EVICTED_REGISTER) === 1n; } @@ -307,7 +307,7 @@ export function storageWrite(key: Bytes, value: Bytes): boolean { * * @param key - The key to be removed. */ -export function storageRemove(key: Bytes): boolean { +export function storageRemove(key: Uint8Array): boolean { return env.storage_remove(key, EVICTED_REGISTER) === 1n; } @@ -321,7 +321,7 @@ export function storageByteCost(): bigint { /** * Returns the arguments passed to the current smart contract call. */ -export function input(): Bytes { +export function input(): Uint8Array { env.input(0); return env.read_register(0); } @@ -331,14 +331,14 @@ export function input(): Bytes { * * @param value - The value to return. */ -export function valueReturn(value: Bytes): void { +export function valueReturn(value: Uint8Array): void { env.value_return(value); } /** * Returns a random string of bytes. */ -export function randomSeed(): Bytes { +export function randomSeed(): Uint8Array { env.random_seed(0); return env.read_register(0); } @@ -353,9 +353,9 @@ export function randomSeed(): Bytes { * @param gas - The amount of Gas attached to the call. */ export function promiseCreate( - accountId: Bytes, - methodName: Bytes, - args: Bytes, + accountId: string, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): PromiseIndex { @@ -380,9 +380,9 @@ export function promiseCreate( */ export function promiseThen( promiseIndex: PromiseIndex, - accountId: Bytes, - methodName: Bytes, - args: Bytes, + accountId: string, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): PromiseIndex { @@ -412,7 +412,7 @@ export function promiseAnd(...promiseIndexes: PromiseIndex[]): PromiseIndex { * * @param accountId - The account ID of the target contract. */ -export function promiseBatchCreate(accountId: Bytes): PromiseIndex { +export function promiseBatchCreate(accountId: string): PromiseIndex { return env.promise_batch_create(accountId) as unknown as PromiseIndex; } @@ -424,7 +424,7 @@ export function promiseBatchCreate(accountId: Bytes): PromiseIndex { */ export function promiseBatchThen( promiseIndex: PromiseIndex, - accountId: Bytes + accountId: string ): PromiseIndex { return env.promise_batch_then( promiseIndex as unknown as bigint, @@ -451,7 +451,7 @@ export function promiseBatchActionCreateAccount( */ export function promiseBatchActionDeployContract( promiseIndex: PromiseIndex, - code: Bytes + code: Uint8Array ): void { env.promise_batch_action_deploy_contract( promiseIndex as unknown as bigint, @@ -470,8 +470,8 @@ export function promiseBatchActionDeployContract( */ export function promiseBatchActionFunctionCall( promiseIndex: PromiseIndex, - methodName: Bytes, - args: Bytes, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount ): void { @@ -507,7 +507,7 @@ export function promiseBatchActionTransfer( export function promiseBatchActionStake( promiseIndex: PromiseIndex, amount: NearAmount, - publicKey: Bytes + publicKey: Uint8Array ): void { env.promise_batch_action_stake( promiseIndex as unknown as bigint, @@ -525,7 +525,7 @@ export function promiseBatchActionStake( */ export function promiseBatchActionAddKeyWithFullAccess( promiseIndex: PromiseIndex, - publicKey: Bytes, + publicKey: Uint8Array, nonce: number | bigint ): void { env.promise_batch_action_add_key_with_full_access( @@ -547,11 +547,11 @@ export function promiseBatchActionAddKeyWithFullAccess( */ export function promiseBatchActionAddKeyWithFunctionCall( promiseIndex: PromiseIndex, - publicKey: Bytes, + publicKey: Uint8Array, nonce: number | bigint, allowance: NearAmount, - receiverId: Bytes, - methodNames: Bytes + receiverId: string, + methodNames: string ): void { env.promise_batch_action_add_key_with_function_call( promiseIndex as unknown as bigint, @@ -571,7 +571,7 @@ export function promiseBatchActionAddKeyWithFunctionCall( */ export function promiseBatchActionDeleteKey( promiseIndex: PromiseIndex, - publicKey: Bytes + publicKey: Uint8Array ): void { env.promise_batch_action_delete_key( promiseIndex as unknown as bigint, @@ -587,7 +587,7 @@ export function promiseBatchActionDeleteKey( */ export function promiseBatchActionDeleteAccount( promiseIndex: PromiseIndex, - beneficiaryId: Bytes + beneficiaryId: string ): void { env.promise_batch_action_delete_account( promiseIndex as unknown as bigint, @@ -607,8 +607,8 @@ export function promiseBatchActionDeleteAccount( */ export function promiseBatchActionFunctionCallWeight( promiseIndex: PromiseIndex, - methodName: Bytes, - args: Bytes, + methodName: string, + args: Uint8Array, amount: NearAmount, gas: NearAmount, weight: GasWeight @@ -635,7 +635,7 @@ export function promiseResultsCount(): bigint { * * @param promiseIndex - The index of the promise to return the result for. */ -export function promiseResult(promiseIndex: PromiseIndex): Bytes { +export function promiseResult(promiseIndex: PromiseIndex): Uint8Array { const status = env.promise_result(promiseIndex as unknown as bigint, 0); assert( @@ -661,32 +661,32 @@ export function promiseReturn(promiseIndex: PromiseIndex): void { env.promise_return(promiseIndex as unknown as bigint); } -export function sha256(value: Bytes): Bytes { +export function sha256(value: Uint8Array): Uint8Array { env.sha256(value, 0); return env.read_register(0); } -export function keccak256(value: Bytes): Bytes { +export function keccak256(value: Uint8Array): Uint8Array { env.keccak256(value, 0); return env.read_register(0); } -export function keccak512(value: Bytes): Bytes { +export function keccak512(value: Uint8Array): Uint8Array { env.keccak512(value, 0); return env.read_register(0); } -export function ripemd160(value: Bytes): Bytes { +export function ripemd160(value: Uint8Array): Uint8Array { env.ripemd160(value, 0); return env.read_register(0); } export function ecrecover( - hash: Bytes, - sig: Bytes, + hash: Uint8Array, + sig: Uint8Array, v: number, malleabilityFlag: number -): Bytes | null { +): Uint8Array | null { const returnValue = env.ecrecover(hash, sig, v, malleabilityFlag, 0); if (returnValue === 0n) { @@ -698,19 +698,19 @@ export function ecrecover( // NOTE: "env.panic(msg)" is not exported, use "throw Error(msg)" instead -export function panicUtf8(msg: Bytes): never { +export function panicUtf8(msg: Uint8Array): never { env.panic_utf8(msg); } -export function logUtf8(msg: Bytes) { +export function logUtf8(msg: Uint8Array) { env.log_utf8(msg); } -export function logUtf16(msg: Bytes) { +export function logUtf16(msg: Uint8Array) { env.log_utf16(msg); } -export function validatorStake(accountId: Bytes): bigint { +export function validatorStake(accountId: string): bigint { return env.validator_stake(accountId); } @@ -718,16 +718,16 @@ export function validatorTotalStake(): bigint { return env.validator_total_stake(); } -export function altBn128G1Multiexp(value: Bytes): Bytes { +export function altBn128G1Multiexp(value: Uint8Array): Uint8Array { env.alt_bn128_g1_multiexp(value, 0); return env.read_register(0); } -export function altBn128G1Sum(value: Bytes): Bytes { +export function altBn128G1Sum(value: Uint8Array): Uint8Array { env.alt_bn128_g1_sum(value, 0); return env.read_register(0); } -export function altBn128PairingCheck(value: Bytes): boolean { +export function altBn128PairingCheck(value: Uint8Array): boolean { return env.alt_bn128_pairing_check(value) === 1n; } From a78156d24cdd4ce49ebe6e92e060b40f6c858d5f Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 22 Nov 2022 17:55:59 +0800 Subject: [PATCH 02/24] reset builder --- builder/builder.c | 2172 +++++++++++++++++++++------------------------ 1 file changed, 1036 insertions(+), 1136 deletions(-) diff --git a/builder/builder.c b/builder/builder.c index cecd2dd52..0e34df0b5 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -1,1136 +1,1036 @@ -#include -#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" -#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" -#include "code.h" - -static JSContext *JS_NewCustomContext(JSRuntime *rt) -{ - JSContext *ctx = JS_NewContextRaw(rt); - if (!ctx) - return NULL; - JS_AddIntrinsicBaseObjects(ctx); - JS_AddIntrinsicDate(ctx); - JS_AddIntrinsicEval(ctx); - JS_AddIntrinsicStringNormalize(ctx); - JS_AddIntrinsicRegExp(ctx); - JS_AddIntrinsicJSON(ctx); - JS_AddIntrinsicProxy(ctx); - JS_AddIntrinsicMapSet(ctx); - JS_AddIntrinsicTypedArrays(ctx); - JS_AddIntrinsicPromise(ctx); - JS_AddIntrinsicBigInt(ctx); - return ctx; -} - -#define DEFINE_NEAR_METHOD(name) \ - void name () __attribute__((export_name(#name))) {\ - JSRuntime *rt;\ - JSContext *ctx;\ - JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ - const char *error_message_c, *error_stack_c;\ - char *error_c;\ - size_t msg_len, stack_len;\ - rt = JS_NewRuntime();\ - ctx = JS_NewCustomContext(rt);\ - js_add_near_host_functions(ctx);\ - mod_obj = js_load_module_binary(ctx, code, code_size);\ - fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ - result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ - if (JS_IsException(result)) {\ - error = JS_GetException(ctx);\ - error_message = JS_GetPropertyStr(ctx, error, "message");\ - error_stack = JS_GetPropertyStr(ctx, error, "stack");\ - error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ - error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ - error_c = malloc(msg_len+1+stack_len);\ - strncpy(error_c, error_message_c, msg_len);\ - error_c[msg_len] = '\n';\ - strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ - panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ - }\ - js_std_loop(ctx);\ - } - -// ############# -// # Registers # -// ############# -extern void read_register(uint64_t register_id, uint64_t ptr); -extern uint64_t register_len(uint64_t register_id); -extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); -// ############### -// # Context API # -// ############### -extern void current_account_id(uint64_t register_id); -extern void signer_account_id(uint64_t register_id); -extern void signer_account_pk(uint64_t register_id); -extern void predecessor_account_id(uint64_t register_id); -extern void input(uint64_t register_id); -extern uint64_t block_index(); -extern uint64_t block_timestamp(); -extern uint64_t epoch_height(); -extern uint64_t storage_usage(); -// ################# -// # Economics API # -// ################# -extern void account_balance(uint64_t balance_ptr); -extern void account_locked_balance(uint64_t balance_ptr); -extern void attached_deposit(uint64_t balance_ptr); -extern uint64_t prepaid_gas(); -extern uint64_t used_gas(); -// ############ -// # Math API # -// ############ -extern void random_seed(uint64_t register_id); -extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); -// ##################### -// # Miscellaneous API # -// ##################### -extern void value_return(uint64_t value_len, uint64_t value_ptr); -extern void panic(void); -extern void panic_utf8(uint64_t len, uint64_t ptr); -extern void log_utf8(uint64_t len, uint64_t ptr); -extern void log_utf16(uint64_t len, uint64_t ptr); -// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade -// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. -// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); -// ################ -// # Promises API # -// ################ -extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); -extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); -extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); -// ####################### -// # Promise API actions # -// ####################### -extern void promise_batch_action_create_account(uint64_t promise_index); -extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); -extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); -extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); -extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); -extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); -extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); -// ####################### -// # Promise API results # -// ####################### -extern uint64_t promise_results_count(void); -extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); -extern void promise_return(uint64_t promise_idx); -// ############### -// # Storage API # -// ############### -extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); -// ################# -// # Validator API # -// ################# -extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); -extern void validator_total_stake(uint64_t stake_ptr); -// ############# -// # Alt BN128 # -// ############# -#ifdef NIGHTLY -extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); -#endif - -static uint8_t* JS_Uint8Array_to_C(JSContext *ctx, JSValue array, size_t *len) { - uint8_t *ptr; - JSValue buffer; - size_t pbyte_offset, psize, pbytes_per_element = 0; - - buffer = JS_GetTypedArrayBuffer(ctx, array, &pbyte_offset, len, &pbytes_per_element); - if (JS_IsException(buffer) || pbytes_per_element != 1) { - return NULL; - } - ptr = JS_GetArrayBuffer(ctx, &psize, buffer); - if (ptr == NULL) { - return NULL; - } - return ptr + pbyte_offset; -} - -static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data; - uint64_t data_len; - JSValue arraybuffer, ret; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_len = register_len(register_id); - if (data_len != UINT64_MAX) { - data = malloc(data_len); - read_register(register_id, (uint64_t)data); - arraybuffer = JS_NewArrayBuffer(ctx, data, (size_t)data_len, NULL, NULL, TRUE); - return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); - } else { - return JS_UNDEFINED; - } -} - -static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id, len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - len = register_len(register_id); - return JS_NewBigUint64(ctx, len); -} - -static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_ptr = JS_Uint8Array_to_C(ctx, argv[1], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - - write_register(register_id, data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - current_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_pk(register_id); - return JS_UNDEFINED; -} - -static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - predecessor_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - input(register_id); - return JS_UNDEFINED; -} - -static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_index(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_timestamp(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = epoch_height(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = storage_usage(); - return JS_NewBigUint64(ctx, value); -} - -// ptr[0] ptr[1] is little-endian u128. -static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { - JSValue value; - bf_t* bn; - bf_t b; - - value = JS_NewBigInt(ctx); - bn = JS_GetBigInt(value); - // from ptr[] to bn - // high 64 bits - bf_set_ui(bn, ptr[1]); - bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); - // low 64 bits - bf_init(bn->ctx, &b); - bf_set_ui(&b, ptr[0]); - bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); - bf_delete(&b); - - return value; -} - -static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - bf_t* a; - bf_t q, r, b, one, u128max; - a = JS_GetBigInt(val); - bf_init(a->ctx, &u128max); - bf_set_ui(&u128max, 1); - bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); - if (bf_cmp_le(&u128max, a)) { - return 1; - } - bf_init(a->ctx, &q); - bf_init(a->ctx, &r); - bf_init(a->ctx, &b); - bf_init(a->ctx, &one); - bf_set_ui(&b, UINT64_MAX); - bf_set_ui(&one, 1); - bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); - bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); - - bf_get_uint64(ptr, &r); - bf_get_uint64(ptr+1, &q); - return 0; -} - -static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_ToUint64Ext(ctx, ptr, val) < 0) { - return 1; - } - ptr[1] = 0; - return 0; -} - -static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_IsBigInt(ctx, val)) - return quickjs_bigint_to_u128(ctx, val, ptr); - else { - return quickjs_int_to_u128(ctx, val, ptr); - } -} - -static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_locked_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - attached_deposit((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = prepaid_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = used_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - random_seed(register_id); - return JS_UNDEFINED; -} - -static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - sha256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - keccak256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - keccak512(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - ripemd160(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t malleability_flag, v, register_id, result; - uint8_t *hash_ptr, *sig_ptr; - size_t hash_len, sign_len; - - hash_ptr = JS_Uint8Array_to_C(ctx, argv[0], &hash_len); - if (hash_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for hash"); - } - sig_ptr = JS_Uint8Array_to_C(ctx, argv[1], &sign_len); - if (sig_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for sig"); - } - if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); - } - if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); - return JS_NewBigUint64(ctx, result); -} - -static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *value_ptr; - size_t value_len; - - value_ptr = JS_Uint8Array_to_C(ctx, argv[0], &value_len); - if (value_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); - } - value_return(value_len, (uint64_t)(value_ptr)); - return JS_UNDEFINED; -} - -static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - if (argc == 1) { - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - panic_utf8(data_len, (uint64_t)data_ptr); - } else { - panic(); - } - return JS_UNDEFINED; -} - -static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - panic_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - log_utf16(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr, *method_name_ptr; - uint8_t *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr, *method_name_ptr; - uint8_t *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[3], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx_ptr[argc], ret; - - for(int i = 0; i < argc; i++) { - if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); - } - } - ret = promise_and((uint64_t)promise_idx_ptr, argc); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - promise_batch_action_create_account(promise_index); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *code_ptr; - size_t code_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - code_ptr = JS_Uint8Array_to_C(ctx, argv[1], &code_len); - if (code_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for code"); - } - promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr; - uint8_t *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; // amount is u128 - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; - uint8_t *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[2], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - - promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *public_key_ptr; - size_t public_key_len; - uint64_t nonce; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *receiver_id_ptr, *method_names_ptr; - uint8_t *public_key_ptr; - size_t public_key_len, receiver_id_len, method_names_len; - uint64_t nonce, allowance_ptr[2]; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); - } - receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); - method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); - - promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr, *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - uint64_t weight; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); - } - promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *beneficiary_id_ptr; - size_t beneficiary_id_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); - promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = promise_results_count(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t result_idx, register_id; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = promise_result(result_idx, register_id); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx; - if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); - } - promise_return(promise_idx); - - return JS_UNDEFINED; -} - -static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr, *value_ptr; - size_t key_len, value_len; - uint64_t register_id, ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - value_ptr = JS_Uint8Array_to_C(ctx, argv[1], &value_len); - if (value_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_read(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - ret = storage_has_key(key_len, (uint64_t)key_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t stake_ptr[2]; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); - - return u128_to_quickjs(ctx, stake_ptr); -} - -static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t stake_ptr[2]; - - validator_total_stake((uint64_t)stake_ptr); - return u128_to_quickjs(ctx, stake_ptr); -} - -#ifdef NIGHTLY -static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - uint64_t ret; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); - return JS_NewBigUint64(ctx, ret); -} -#endif - -static void js_add_near_host_functions(JSContext* ctx) { - JSValue global_obj, env; - - global_obj = JS_GetGlobalObject(ctx); - env = JS_NewObject(ctx); - - JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); - JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); - JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); - JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); - JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); - JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); - JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); - JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); - JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); - JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); - JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); - JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); - JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); - JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); - JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); - JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); - JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); - JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); - JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); - JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); - JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); - JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); - JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); - JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); - JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); - JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_utf8", 1)); - JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); - JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); - JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); - JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); - JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); - JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); - JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); - JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); - JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); - JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); - JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); - JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); - JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); - #ifdef NIGHTLY - // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet -// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); - #endif - - JS_SetPropertyStr(ctx, global_obj, "env", env); -} - -JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, - int argc, JSValueConst *argv); - -void _start() {} - -#include "methods.h" +#include +#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/quickjs-libc-min.h" +#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/libbf.h" +#include "code.h" + +static JSContext *JS_NewCustomContext(JSRuntime *rt) +{ + JSContext *ctx = JS_NewContextRaw(rt); + if (!ctx) + return NULL; + JS_AddIntrinsicBaseObjects(ctx); + JS_AddIntrinsicDate(ctx); + JS_AddIntrinsicEval(ctx); + JS_AddIntrinsicStringNormalize(ctx); + JS_AddIntrinsicRegExp(ctx); + JS_AddIntrinsicJSON(ctx); + JS_AddIntrinsicProxy(ctx); + JS_AddIntrinsicMapSet(ctx); + JS_AddIntrinsicTypedArrays(ctx); + JS_AddIntrinsicPromise(ctx); + JS_AddIntrinsicBigInt(ctx); + return ctx; +} + +#define DEFINE_NEAR_METHOD(name) \ + void name () __attribute__((export_name(#name))) {\ + JSRuntime *rt;\ + JSContext *ctx;\ + JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ + const char *error_message_c, *error_stack_c;\ + char *error_c;\ + size_t msg_len, stack_len;\ + rt = JS_NewRuntime();\ + ctx = JS_NewCustomContext(rt);\ + js_add_near_host_functions(ctx);\ + mod_obj = js_load_module_binary(ctx, code, code_size);\ + fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ + result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ + if (JS_IsException(result)) {\ + error = JS_GetException(ctx);\ + error_message = JS_GetPropertyStr(ctx, error, "message");\ + error_stack = JS_GetPropertyStr(ctx, error, "stack");\ + error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ + error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ + error_c = malloc(msg_len+1+stack_len);\ + strncpy(error_c, error_message_c, msg_len);\ + error_c[msg_len] = '\n';\ + strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ + panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ + }\ + js_std_loop(ctx);\ + } + +// ############# +// # Registers # +// ############# +extern void read_register(uint64_t register_id, uint64_t ptr); +extern uint64_t register_len(uint64_t register_id); +extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); +// ############### +// # Context API # +// ############### +extern void current_account_id(uint64_t register_id); +extern void signer_account_id(uint64_t register_id); +extern void signer_account_pk(uint64_t register_id); +extern void predecessor_account_id(uint64_t register_id); +extern void input(uint64_t register_id); +extern uint64_t block_index(); +extern uint64_t block_timestamp(); +extern uint64_t epoch_height(); +extern uint64_t storage_usage(); +// ################# +// # Economics API # +// ################# +extern void account_balance(uint64_t balance_ptr); +extern void account_locked_balance(uint64_t balance_ptr); +extern void attached_deposit(uint64_t balance_ptr); +extern uint64_t prepaid_gas(); +extern uint64_t used_gas(); +// ############ +// # Math API # +// ############ +extern void random_seed(uint64_t register_id); +extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); +// ##################### +// # Miscellaneous API # +// ##################### +extern void value_return(uint64_t value_len, uint64_t value_ptr); +extern void panic(void); +extern void panic_utf8(uint64_t len, uint64_t ptr); +extern void log_utf8(uint64_t len, uint64_t ptr); +extern void log_utf16(uint64_t len, uint64_t ptr); +// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade +// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. +// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); +// ################ +// # Promises API # +// ################ +extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); +extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); +extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); +// ####################### +// # Promise API actions # +// ####################### +extern void promise_batch_action_create_account(uint64_t promise_index); +extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); +extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); +extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); +extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); +extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); +extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); +// ####################### +// # Promise API results # +// ####################### +extern uint64_t promise_results_count(void); +extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); +extern void promise_return(uint64_t promise_idx); +// ############### +// # Storage API # +// ############### +extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); +// ################# +// # Validator API # +// ################# +extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); +extern void validator_total_stake(uint64_t stake_ptr); +// ############# +// # Alt BN128 # +// ############# +#ifdef NIGHTLY +extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); +#endif + +static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + char *data; + uint64_t data_len; + JSValue ret; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_len = register_len(register_id); + if (data_len != UINT64_MAX) { + data = malloc(data_len); + read_register(register_id, (uint64_t)data); + ret = JS_NewStringLenRaw(ctx, data, data_len); + free(data); + return ret; + } else { + return JS_UNDEFINED; + } +} + +static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id, len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + len = register_len(register_id); + return JS_NewBigUint64(ctx, len); +} + +static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[1]); + + write_register(register_id, data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + current_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_pk(register_id); + return JS_UNDEFINED; +} + +static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + predecessor_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + input(register_id); + return JS_UNDEFINED; +} + +static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_index(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_timestamp(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = epoch_height(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = storage_usage(); + return JS_NewBigUint64(ctx, value); +} + +// ptr[0] ptr[1] is little-endian u128. +static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { + JSValue value; + bf_t* bn; + bf_t b; + + value = JS_NewBigInt(ctx); + bn = JS_GetBigInt(value); + // from ptr[] to bn + // high 64 bits + bf_set_ui(bn, ptr[1]); + bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); + // low 64 bits + bf_init(bn->ctx, &b); + bf_set_ui(&b, ptr[0]); + bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); + bf_delete(&b); + + return value; +} + +static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + bf_t* a; + bf_t q, r, b, one, u128max; + a = JS_GetBigInt(val); + bf_init(a->ctx, &u128max); + bf_set_ui(&u128max, 1); + bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); + if (bf_cmp_le(&u128max, a)) { + return 1; + } + bf_init(a->ctx, &q); + bf_init(a->ctx, &r); + bf_init(a->ctx, &b); + bf_init(a->ctx, &one); + bf_set_ui(&b, UINT64_MAX); + bf_set_ui(&one, 1); + bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); + bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); + + bf_get_uint64(ptr, &r); + bf_get_uint64(ptr+1, &q); + return 0; +} + +static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_ToUint64Ext(ctx, ptr, val) < 0) { + return 1; + } + ptr[1] = 0; + return 0; +} + +static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_IsBigInt(ctx, val)) + return quickjs_bigint_to_u128(ctx, val, ptr); + else { + return quickjs_int_to_u128(ctx, val, ptr); + } +} + +static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_locked_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + attached_deposit((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = prepaid_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = used_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + random_seed(register_id); + return JS_UNDEFINED; +} + +static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + sha256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + keccak256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + keccak512(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + ripemd160(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t malleability_flag, v, register_id, result; + const char *hash_ptr, *sig_ptr; + size_t hash_len, sign_len; + + hash_ptr = JS_ToCStringLenRaw(ctx, &hash_len, argv[0]); + sig_ptr = JS_ToCStringLenRaw(ctx, &sign_len, argv[1]); + if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); + } + if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); + return JS_NewBigUint64(ctx, result); +} + +static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *value_ptr; + size_t value_len; + + value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[0]); + value_return(value_len, (uint64_t)value_ptr); + return JS_UNDEFINED; +} + +static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + if (argc == 1) { + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + panic_utf8(data_len, (uint64_t)data_ptr); + } else { + panic(); + } + return JS_UNDEFINED; +} + +static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + + panic_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + log_utf16(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr, *method_name_ptr, *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr, *method_name_ptr, *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[3]); + if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx_ptr[argc], ret; + + for(int i = 0; i < argc; i++) { + if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); + } + } + ret = promise_and((uint64_t)promise_idx_ptr, argc); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + promise_batch_action_create_account(promise_index); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *code_ptr; + size_t code_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + code_ptr = JS_ToCStringLenRaw(ctx, &code_len, argv[1]); + promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr, *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; // amount is u128 + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; + const char *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[2]); + + promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *public_key_ptr; + size_t public_key_len; + uint64_t nonce; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *public_key_ptr, *receiver_id_ptr, *method_names_ptr; + size_t public_key_len, receiver_id_len, method_names_len; + uint64_t nonce, allowance_ptr[2]; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); + } + receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); + method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); + + promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr, *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + uint64_t weight; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); + } + promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *beneficiary_id_ptr; + size_t beneficiary_id_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); + promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = promise_results_count(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t result_idx, register_id; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = promise_result(result_idx, register_id); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx; + if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); + } + promise_return(promise_idx); + + return JS_UNDEFINED; +} + +static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *key_ptr, *value_ptr; + size_t key_len, value_len; + uint64_t register_id, ret; + + key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[1]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_read(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *key_ptr; + size_t key_len; + uint64_t ret; + + key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + ret = storage_has_key(key_len, (uint64_t)key_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t stake_ptr[2]; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); + + return u128_to_quickjs(ctx, stake_ptr); +} + +static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t stake_ptr[2]; + + validator_total_stake((uint64_t)stake_ptr); + return u128_to_quickjs(ctx, stake_ptr); +} + +#ifdef NIGHTLY +static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + uint64_t ret; + + data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + + ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); + return JS_NewBigUint64(ctx, ret); +} +#endif + +static void js_add_near_host_functions(JSContext* ctx) { + JSValue global_obj, env; + + global_obj = JS_GetGlobalObject(ctx); + env = JS_NewObject(ctx); + + JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); + JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); + JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); + JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); + JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); + JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); + JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); + JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); + JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); + JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); + JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); + JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); + JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); + JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); + JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); + JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); + JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); + JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); + JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); + JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); + JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); + JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); + JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); + JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); + JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); + JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_utf8", 1)); + JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); + JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); + JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); + JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); + JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); + JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); + JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); + JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); + JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); + JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); + JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); + JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); + JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); + #ifdef NIGHTLY + // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet +// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); + #endif + + JS_SetPropertyStr(ctx, global_obj, "env", env); +} + +JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, + int argc, JSValueConst *argv); + +void _start() {} + +#include "methods.h" From 5187700a16aa700365fc9becda1002457edad695 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 22 Nov 2022 17:58:23 +0800 Subject: [PATCH 03/24] update builder.c, fix git diff --- builder/builder.c | 224 +++++--- cli/builder/builder.c | 1136 +++++++++++++++++++++++++++++++++++++++++ src/api.ts | 18 +- 3 files changed, 1313 insertions(+), 65 deletions(-) create mode 100644 cli/builder/builder.c diff --git a/builder/builder.c b/builder/builder.c index 0e34df0b5..c25984dba 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -1,6 +1,6 @@ #include -#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/quickjs-libc-min.h" -#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/libbf.h" +#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" +#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" #include "code.h" static JSContext *JS_NewCustomContext(JSRuntime *rt) @@ -145,12 +145,28 @@ extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t re extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); #endif +static uint8_t* JS_Uint8Array_to_C(JSContext *ctx, JSValue array, size_t *len) { + uint8_t *ptr; + JSValue buffer; + size_t pbyte_offset, psize, pbytes_per_element = 0; + + buffer = JS_GetTypedArrayBuffer(ctx, array, &pbyte_offset, len, &pbytes_per_element); + if (JS_IsException(buffer) || pbytes_per_element != 1) { + return NULL; + } + ptr = JS_GetArrayBuffer(ctx, &psize, buffer); + if (ptr == NULL) { + return NULL; + } + return ptr + pbyte_offset; +} + static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - char *data; + uint8_t *data; uint64_t data_len; - JSValue ret; + JSValue arraybuffer, ret; if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); @@ -159,9 +175,8 @@ static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int arg if (data_len != UINT64_MAX) { data = malloc(data_len); read_register(register_id, (uint64_t)data); - ret = JS_NewStringLenRaw(ctx, data, data_len); - free(data); - return ret; + arraybuffer = JS_NewArrayBuffer(ctx, data, (size_t)data_len, NULL, NULL, TRUE); + return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); } else { return JS_UNDEFINED; } @@ -181,13 +196,16 @@ static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[1]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[1], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } write_register(register_id, data_len, (uint64_t)data_ptr); return JS_UNDEFINED; @@ -392,10 +410,13 @@ static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -407,10 +428,13 @@ static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSVa static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -421,10 +445,13 @@ static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, J static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -436,10 +463,13 @@ static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, J static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -451,11 +481,17 @@ static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, J static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t malleability_flag, v, register_id, result; - const char *hash_ptr, *sig_ptr; + uint8_t *hash_ptr, *sig_ptr; size_t hash_len, sign_len; - hash_ptr = JS_ToCStringLenRaw(ctx, &hash_len, argv[0]); - sig_ptr = JS_ToCStringLenRaw(ctx, &sign_len, argv[1]); + hash_ptr = JS_Uint8Array_to_C(ctx, argv[0], &hash_len); + if (hash_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for hash"); + } + sig_ptr = JS_Uint8Array_to_C(ctx, argv[1], &sign_len); + if (sig_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for sig"); + } if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); } @@ -472,11 +508,14 @@ static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, J static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *value_ptr; + uint8_t *value_ptr; size_t value_len; - value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[0]); - value_return(value_len, (uint64_t)value_ptr); + value_ptr = JS_Uint8Array_to_C(ctx, argv[0], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } + value_return(value_len, (uint64_t)(value_ptr)); return JS_UNDEFINED; } @@ -496,10 +535,13 @@ static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSVal static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } panic_utf8(data_len, (uint64_t)data_ptr); return JS_UNDEFINED; @@ -518,35 +560,46 @@ static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValue static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + log_utf8(data_len, (uint64_t)data_ptr); return JS_UNDEFINED; } static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + log_utf16(data_len, (uint64_t)data_ptr); return JS_UNDEFINED; } static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *account_id_ptr, *method_name_ptr, *arguments_ptr; + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; size_t account_id_len, method_name_len, arguments_len; uint64_t amount_ptr[2]; // amount is u128 uint64_t gas, ret; account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); } @@ -562,7 +615,8 @@ static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int ar static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *account_id_ptr, *method_name_ptr, *arguments_ptr; + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; size_t account_id_len, method_name_len, arguments_len; uint64_t amount_ptr[2]; // amount is u128 uint64_t gas, ret; @@ -572,7 +626,10 @@ static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc } account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[3]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[3], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); } @@ -638,13 +695,16 @@ static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueC static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *code_ptr; + uint8_t *code_ptr; size_t code_len; if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); } - code_ptr = JS_ToCStringLenRaw(ctx, &code_len, argv[1]); + code_ptr = JS_Uint8Array_to_C(ctx, argv[1], &code_len); + if (code_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for code"); + } promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); return JS_UNDEFINED; } @@ -652,7 +712,8 @@ static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValue static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *method_name_ptr, *arguments_ptr; + const char *method_name_ptr; + uint8_t *arguments_ptr; size_t method_name_len, arguments_len; uint64_t amount_ptr[2]; // amount is u128 uint64_t gas; @@ -661,7 +722,10 @@ static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueCo return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); } method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); } @@ -691,7 +755,7 @@ static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this { uint64_t promise_index; uint64_t amount_ptr[2]; - const char *public_key_ptr; + uint8_t *public_key_ptr; size_t public_key_len; if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { @@ -700,7 +764,10 @@ static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[2]); + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[2], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); return JS_UNDEFINED; @@ -709,14 +776,17 @@ static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *public_key_ptr; + uint8_t *public_key_ptr; size_t public_key_len; uint64_t nonce; if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); } @@ -727,14 +797,18 @@ static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *public_key_ptr, *receiver_id_ptr, *method_names_ptr; + const char *receiver_id_ptr, *method_names_ptr; + uint8_t *public_key_ptr; size_t public_key_len, receiver_id_len, method_names_len; uint64_t nonce, allowance_ptr[2]; if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); } @@ -751,13 +825,16 @@ static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *c static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t promise_index; - const char *public_key_ptr; + uint8_t *public_key_ptr; size_t public_key_len; if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); } - public_key_ptr = JS_ToCStringLenRaw(ctx, &public_key_len, argv[1]); + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); return JS_UNDEFINED; } @@ -840,12 +917,18 @@ static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int ar static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *key_ptr, *value_ptr; + uint8_t *key_ptr, *value_ptr; size_t key_len, value_len; uint64_t register_id, ret; - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); - value_ptr = JS_ToCStringLenRaw(ctx, &value_len, argv[1]); + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + value_ptr = JS_Uint8Array_to_C(ctx, argv[1], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -855,12 +938,15 @@ static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int arg static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *key_ptr; + uint8_t *key_ptr; size_t key_len; uint64_t register_id; uint64_t ret; - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -870,12 +956,15 @@ static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *key_ptr; + uint8_t *key_ptr; size_t key_len; uint64_t register_id; uint64_t ret; - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -885,11 +974,14 @@ static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int ar static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *key_ptr; + uint8_t *key_ptr; size_t key_len; uint64_t ret; - key_ptr = JS_ToCStringLenRaw(ctx, &key_len, argv[0]); + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } ret = storage_has_key(key_len, (uint64_t)key_ptr); return JS_NewBigUint64(ctx, ret); } @@ -918,10 +1010,13 @@ static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -933,10 +1028,13 @@ static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { uint64_t register_id; - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); } @@ -947,12 +1045,14 @@ static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - const char *data_ptr; + uint8_t *data_ptr; size_t data_len; uint64_t ret; - data_ptr = JS_ToCStringLenRaw(ctx, &data_len, argv[0]); - + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); return JS_NewBigUint64(ctx, ret); } diff --git a/cli/builder/builder.c b/cli/builder/builder.c new file mode 100644 index 000000000..2d67a723a --- /dev/null +++ b/cli/builder/builder.c @@ -0,0 +1,1136 @@ +#include +#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" +#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" +#include "code.h" + +static JSContext *JS_NewCustomContext(JSRuntime *rt) +{ + JSContext *ctx = JS_NewContextRaw(rt); + if (!ctx) + return NULL; + JS_AddIntrinsicBaseObjects(ctx); + JS_AddIntrinsicDate(ctx); + JS_AddIntrinsicEval(ctx); + JS_AddIntrinsicStringNormalize(ctx); + JS_AddIntrinsicRegExp(ctx); + JS_AddIntrinsicJSON(ctx); + JS_AddIntrinsicProxy(ctx); + JS_AddIntrinsicMapSet(ctx); + JS_AddIntrinsicTypedArrays(ctx); + JS_AddIntrinsicPromise(ctx); + JS_AddIntrinsicBigInt(ctx); + return ctx; +} + +#define DEFINE_NEAR_METHOD(name) \ + void name () __attribute__((export_name(#name))) {\ + JSRuntime *rt;\ + JSContext *ctx;\ + JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ + const char *error_message_c, *error_stack_c;\ + char *error_c;\ + size_t msg_len, stack_len;\ + rt = JS_NewRuntime();\ + ctx = JS_NewCustomContext(rt);\ + js_add_near_host_functions(ctx);\ + mod_obj = js_load_module_binary(ctx, code, code_size);\ + fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ + result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ + if (JS_IsException(result)) {\ + error = JS_GetException(ctx);\ + error_message = JS_GetPropertyStr(ctx, error, "message");\ + error_stack = JS_GetPropertyStr(ctx, error, "stack");\ + error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ + error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ + error_c = malloc(msg_len+1+stack_len);\ + strncpy(error_c, error_message_c, msg_len);\ + error_c[msg_len] = '\n';\ + strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ + panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ + }\ + js_std_loop(ctx);\ + } + +// ############# +// # Registers # +// ############# +extern void read_register(uint64_t register_id, uint64_t ptr); +extern uint64_t register_len(uint64_t register_id); +extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); +// ############### +// # Context API # +// ############### +extern void current_account_id(uint64_t register_id); +extern void signer_account_id(uint64_t register_id); +extern void signer_account_pk(uint64_t register_id); +extern void predecessor_account_id(uint64_t register_id); +extern void input(uint64_t register_id); +extern uint64_t block_index(); +extern uint64_t block_timestamp(); +extern uint64_t epoch_height(); +extern uint64_t storage_usage(); +// ################# +// # Economics API # +// ################# +extern void account_balance(uint64_t balance_ptr); +extern void account_locked_balance(uint64_t balance_ptr); +extern void attached_deposit(uint64_t balance_ptr); +extern uint64_t prepaid_gas(); +extern uint64_t used_gas(); +// ############ +// # Math API # +// ############ +extern void random_seed(uint64_t register_id); +extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); +// ##################### +// # Miscellaneous API # +// ##################### +extern void value_return(uint64_t value_len, uint64_t value_ptr); +extern void panic(void); +extern void panic_utf8(uint64_t len, uint64_t ptr); +extern void log_utf8(uint64_t len, uint64_t ptr); +extern void log_utf16(uint64_t len, uint64_t ptr); +// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade +// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. +// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); +// ################ +// # Promises API # +// ################ +extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); +extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); +extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); +// ####################### +// # Promise API actions # +// ####################### +extern void promise_batch_action_create_account(uint64_t promise_index); +extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); +extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); +extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); +extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); +extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); +extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); +extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); +extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); +// ####################### +// # Promise API results # +// ####################### +extern uint64_t promise_results_count(void); +extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); +extern void promise_return(uint64_t promise_idx); +// ############### +// # Storage API # +// ############### +extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); +extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); +// ################# +// # Validator API # +// ################# +extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); +extern void validator_total_stake(uint64_t stake_ptr); +// ############# +// # Alt BN128 # +// ############# +#ifdef NIGHTLY +extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); +extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); +#endif + +static uint8_t* JS_Uint8Array_to_C(JSContext *ctx, JSValue array, size_t *len) { + uint8_t *ptr; + JSValue buffer; + size_t pbyte_offset, psize, pbytes_per_element = 0; + + buffer = JS_GetTypedArrayBuffer(ctx, array, &pbyte_offset, len, &pbytes_per_element); + if (JS_IsException(buffer) || pbytes_per_element != 1) { + return NULL; + } + ptr = JS_GetArrayBuffer(ctx, &psize, buffer); + if (ptr == NULL) { + return NULL; + } + return ptr + pbyte_offset; +} + +static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data; + uint64_t data_len; + JSValue arraybuffer, ret; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_len = register_len(register_id); + if (data_len != UINT64_MAX) { + data = malloc(data_len); + read_register(register_id, (uint64_t)data); + arraybuffer = JS_NewArrayBuffer(ctx, data, (size_t)data_len, NULL, NULL, TRUE); + return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); + } else { + return JS_UNDEFINED; + } +} + +static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id, len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + len = register_len(register_id); + return JS_NewBigUint64(ctx, len); +} + +static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + data_ptr = JS_Uint8Array_to_C(ctx, argv[1], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + + write_register(register_id, data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + current_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + signer_account_pk(register_id); + return JS_UNDEFINED; +} + +static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + predecessor_account_id(register_id); + return JS_UNDEFINED; +} + +static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + input(register_id); + return JS_UNDEFINED; +} + +static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_index(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = block_timestamp(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = epoch_height(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = storage_usage(); + return JS_NewBigUint64(ctx, value); +} + +// ptr[0] ptr[1] is little-endian u128. +static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { + JSValue value; + bf_t* bn; + bf_t b; + + value = JS_NewBigInt(ctx); + bn = JS_GetBigInt(value); + // from ptr[] to bn + // high 64 bits + bf_set_ui(bn, ptr[1]); + bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); + // low 64 bits + bf_init(bn->ctx, &b); + bf_set_ui(&b, ptr[0]); + bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); + bf_delete(&b); + + return value; +} + +static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + bf_t* a; + bf_t q, r, b, one, u128max; + a = JS_GetBigInt(val); + bf_init(a->ctx, &u128max); + bf_set_ui(&u128max, 1); + bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); + if (bf_cmp_le(&u128max, a)) { + return 1; + } + bf_init(a->ctx, &q); + bf_init(a->ctx, &r); + bf_init(a->ctx, &b); + bf_init(a->ctx, &one); + bf_set_ui(&b, UINT64_MAX); + bf_set_ui(&one, 1); + bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); + bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); + + bf_get_uint64(ptr, &r); + bf_get_uint64(ptr+1, &q); + return 0; +} + +static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_ToUint64Ext(ctx, ptr, val) < 0) { + return 1; + } + ptr[1] = 0; + return 0; +} + +static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { + if (JS_IsBigInt(ctx, val)) + return quickjs_bigint_to_u128(ctx, val, ptr); + else { + return quickjs_int_to_u128(ctx, val, ptr); + } +} + +static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + account_locked_balance((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t ptr[2]; + + attached_deposit((uint64_t)ptr); + return u128_to_quickjs(ctx, ptr); +} + +static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = prepaid_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = used_gas(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + + if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + random_seed(register_id); + return JS_UNDEFINED; +} + +static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + sha256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + keccak256(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + keccak512(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + ripemd160(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t malleability_flag, v, register_id, result; + uint8_t *hash_ptr, *sig_ptr; + size_t hash_len, sign_len; + + hash_ptr = JS_Uint8Array_to_C(ctx, argv[0], &hash_len); + if (hash_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for hash"); + } + sig_ptr = JS_Uint8Array_to_C(ctx, argv[1], &sign_len); + if (sig_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for sig"); + } + if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); + } + if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); + return JS_NewBigUint64(ctx, result); +} + +static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *value_ptr; + size_t value_len; + + value_ptr = JS_Uint8Array_to_C(ctx, argv[0], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } + value_return(value_len, (uint64_t)(value_ptr)); + return JS_UNDEFINED; +} + +static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + if (argc == 1) { + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + panic_utf8(data_len, (uint64_t)data_ptr); + } else { + panic(); + } + return JS_UNDEFINED; +} + +static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + panic_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *data_ptr; + size_t data_len; + + data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + log_utf8(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); + } + + log_utf16(data_len, (uint64_t)data_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr, *method_name_ptr; + uint8_t *arguments_ptr; + size_t account_id_len, method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas, ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[3], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + + ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx_ptr[argc], ret; + + for(int i = 0; i < argc; i++) { + if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); + } + } + ret = promise_and((uint64_t)promise_idx_ptr, argc); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *account_id_ptr; + size_t account_id_len; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); + ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + promise_batch_action_create_account(promise_index); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *code_ptr; + size_t code_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + code_ptr = JS_Uint8Array_to_C(ctx, argv[1], &code_len); + if (code_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for code"); + } + promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr; + uint8_t *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); + if (arguments_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); + } + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; // amount is u128 + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint64_t amount_ptr[2]; + uint8_t *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[2], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + + promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *public_key_ptr; + size_t public_key_len; + uint64_t nonce; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *receiver_id_ptr, *method_names_ptr; + uint8_t *public_key_ptr; + size_t public_key_len, receiver_id_len, method_names_len; + uint64_t nonce, allowance_ptr[2]; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); + } + if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); + } + receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); + method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); + + promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + uint8_t *public_key_ptr; + size_t public_key_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); + if (public_key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); + } + promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *method_name_ptr, *arguments_ptr; + size_t method_name_len, arguments_len; + uint64_t amount_ptr[2]; // amount is u128 + uint64_t gas; + uint64_t weight; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); + arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); + if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { + return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); + } + if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); + } + if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); + } + promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); + return JS_UNDEFINED; +} + +static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_index; + const char *beneficiary_id_ptr; + size_t beneficiary_id_len; + + if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); + } + beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); + promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); + return JS_UNDEFINED; +} + +static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t value; + + value = promise_results_count(); + return JS_NewBigUint64(ctx, value); +} + +static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t result_idx, register_id; + uint64_t ret; + + if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = promise_result(result_idx, register_id); + + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t promise_idx; + if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); + } + promise_return(promise_idx); + + return JS_UNDEFINED; +} + +static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr, *value_ptr; + size_t key_len, value_len; + uint64_t register_id, ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + value_ptr = JS_Uint8Array_to_C(ctx, argv[1], &value_len); + if (value_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_read(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t register_id; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *key_ptr; + size_t key_len; + uint64_t ret; + + key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); + if (key_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); + } + ret = storage_has_key(key_len, (uint64_t)key_ptr); + return JS_NewBigUint64(ctx, ret); +} + +static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + const char *account_id_ptr; + size_t account_id_len; + uint64_t stake_ptr[2]; + + account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); + validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); + + return u128_to_quickjs(ctx, stake_ptr); +} + +static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t stake_ptr[2]; + + validator_total_stake((uint64_t)stake_ptr); + return u128_to_quickjs(ctx, stake_ptr); +} + +#ifdef NIGHTLY +static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint64_t register_id; + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { + return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); + } + + alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); + return JS_UNDEFINED; +} + +static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + uint64_t ret; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); + } + ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); + return JS_NewBigUint64(ctx, ret); +} +#endif + +static void js_add_near_host_functions(JSContext* ctx) { + JSValue global_obj, env; + + global_obj = JS_GetGlobalObject(ctx); + env = JS_NewObject(ctx); + + JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); + JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); + JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); + JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); + JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); + JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); + JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); + JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); + JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); + JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); + JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); + JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); + JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); + JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); + JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); + JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); + JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); + JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); + JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); + JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); + JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); + JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); + JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); + JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); + JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); + JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); + JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_ut8", 1)); + JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); + JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); + JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); + JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); + JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); + JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); + JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); + JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); + JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); + JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); + JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); + JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); + JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); + JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); + #ifdef NIGHTLY + // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet +// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); + JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); + #endif + + JS_SetPropertyStr(ctx, global_obj, "env", env); +} + +JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, + int argc, JSValueConst *argv); + +void _start() {} + +#include "methods.h" diff --git a/src/api.ts b/src/api.ts index 3493f1059..701fc2d8f 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,4 +1,10 @@ -import { assert, NearAmount, PromiseIndex, Register, u8ArrayToLatin1 } from "./utils"; +import { + assert, + NearAmount, + PromiseIndex, + Register, + u8ArrayToLatin1, +} from "./utils"; import { GasWeight, PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; @@ -85,7 +91,10 @@ interface Env { promise_batch_create(accountId: string): bigint; promise_batch_then(promiseIndex: bigint, accountId: string): bigint; promise_batch_action_create_account(promiseIndex: bigint): void; - promise_batch_action_deploy_contract(promiseIndex: bigint, code: Uint8Array): void; + promise_batch_action_deploy_contract( + promiseIndex: bigint, + code: Uint8Array + ): void; promise_batch_action_function_call( promiseIndex: bigint, methodName: string, @@ -112,7 +121,10 @@ interface Env { receiverId: string, methodNames: string ): void; - promise_batch_action_delete_key(promiseIndex: bigint, publicKey: Uint8Array): void; + promise_batch_action_delete_key( + promiseIndex: bigint, + publicKey: Uint8Array + ): void; promise_batch_action_delete_account( promiseIndex: bigint, beneficiaryId: string From a947408b3d20429d99dd206948b631ad41fa8696 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 22 Nov 2022 17:59:12 +0800 Subject: [PATCH 04/24] nit --- cli/builder/builder.c | 1136 ----------------------------------------- 1 file changed, 1136 deletions(-) delete mode 100644 cli/builder/builder.c diff --git a/cli/builder/builder.c b/cli/builder/builder.c deleted file mode 100644 index 2d67a723a..000000000 --- a/cli/builder/builder.c +++ /dev/null @@ -1,1136 +0,0 @@ -#include -#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" -#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" -#include "code.h" - -static JSContext *JS_NewCustomContext(JSRuntime *rt) -{ - JSContext *ctx = JS_NewContextRaw(rt); - if (!ctx) - return NULL; - JS_AddIntrinsicBaseObjects(ctx); - JS_AddIntrinsicDate(ctx); - JS_AddIntrinsicEval(ctx); - JS_AddIntrinsicStringNormalize(ctx); - JS_AddIntrinsicRegExp(ctx); - JS_AddIntrinsicJSON(ctx); - JS_AddIntrinsicProxy(ctx); - JS_AddIntrinsicMapSet(ctx); - JS_AddIntrinsicTypedArrays(ctx); - JS_AddIntrinsicPromise(ctx); - JS_AddIntrinsicBigInt(ctx); - return ctx; -} - -#define DEFINE_NEAR_METHOD(name) \ - void name () __attribute__((export_name(#name))) {\ - JSRuntime *rt;\ - JSContext *ctx;\ - JSValue mod_obj, fun_obj, result, error, error_message, error_stack;\ - const char *error_message_c, *error_stack_c;\ - char *error_c;\ - size_t msg_len, stack_len;\ - rt = JS_NewRuntime();\ - ctx = JS_NewCustomContext(rt);\ - js_add_near_host_functions(ctx);\ - mod_obj = js_load_module_binary(ctx, code, code_size);\ - fun_obj = JS_GetProperty(ctx, mod_obj, JS_NewAtom(ctx, #name));\ - result = JS_Call(ctx, fun_obj, mod_obj, 0, NULL);\ - if (JS_IsException(result)) {\ - error = JS_GetException(ctx);\ - error_message = JS_GetPropertyStr(ctx, error, "message");\ - error_stack = JS_GetPropertyStr(ctx, error, "stack");\ - error_message_c = JS_ToCStringLen(ctx, &msg_len, error_message);\ - error_stack_c = JS_ToCStringLen(ctx, &stack_len, error_stack);\ - error_c = malloc(msg_len+1+stack_len);\ - strncpy(error_c, error_message_c, msg_len);\ - error_c[msg_len] = '\n';\ - strncpy(error_c+msg_len+1, error_stack_c, stack_len);\ - panic_utf8(msg_len+1+stack_len, (uint64_t)error_c);\ - }\ - js_std_loop(ctx);\ - } - -// ############# -// # Registers # -// ############# -extern void read_register(uint64_t register_id, uint64_t ptr); -extern uint64_t register_len(uint64_t register_id); -extern void write_register(uint64_t register_id, uint64_t data_len, uint64_t data_ptr); -// ############### -// # Context API # -// ############### -extern void current_account_id(uint64_t register_id); -extern void signer_account_id(uint64_t register_id); -extern void signer_account_pk(uint64_t register_id); -extern void predecessor_account_id(uint64_t register_id); -extern void input(uint64_t register_id); -extern uint64_t block_index(); -extern uint64_t block_timestamp(); -extern uint64_t epoch_height(); -extern uint64_t storage_usage(); -// ################# -// # Economics API # -// ################# -extern void account_balance(uint64_t balance_ptr); -extern void account_locked_balance(uint64_t balance_ptr); -extern void attached_deposit(uint64_t balance_ptr); -extern uint64_t prepaid_gas(); -extern uint64_t used_gas(); -// ############ -// # Math API # -// ############ -extern void random_seed(uint64_t register_id); -extern void sha256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak256(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void keccak512(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void ripemd160(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t ecrecover(uint64_t hash_len, uint64_t hash_ptr, uint64_t sign_len, uint64_t sig_ptr, uint64_t v, uint64_t malleability_flag, uint64_t register_id); -// ##################### -// # Miscellaneous API # -// ##################### -extern void value_return(uint64_t value_len, uint64_t value_ptr); -extern void panic(void); -extern void panic_utf8(uint64_t len, uint64_t ptr); -extern void log_utf8(uint64_t len, uint64_t ptr); -extern void log_utf16(uint64_t len, uint64_t ptr); -// Name confliction with WASI. Can be re-exported with a different name on NEAR side with a protocol upgrade -// Or, this is actually not a primitive, can be implement with log and panic host functions in C side or JS side. -// extern void abort(uint32_t msg_ptr, uint32_t filename_ptr, uint32_t u32, uint32_t col); -// ################ -// # Promises API # -// ################ -extern uint64_t promise_create(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern uint64_t promise_and(uint64_t promise_idx_ptr, uint64_t promise_idx_count); -extern uint64_t promise_batch_create(uint64_t account_id_len, uint64_t account_id_ptr); -extern uint64_t promise_batch_then(uint64_t promise_index, uint64_t account_id_len, uint64_t account_id_ptr); -// ####################### -// # Promise API actions # -// ####################### -extern void promise_batch_action_create_account(uint64_t promise_index); -extern void promise_batch_action_deploy_contract(uint64_t promise_index, uint64_t code_len, uint64_t code_ptr); -extern void promise_batch_action_function_call(uint64_t promise_index, uint64_t method_name_len, uint64_t method_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas); -extern void promise_batch_action_transfer(uint64_t promise_index, uint64_t amount_ptr); -extern void promise_batch_action_stake(uint64_t promise_index, uint64_t amount_ptr, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_add_key_with_full_access(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce); -extern void promise_batch_action_add_key_with_function_call(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr, uint64_t nonce, uint64_t allowance_ptr, uint64_t receiver_id_len, uint64_t receiver_id_ptr, uint64_t method_names_len, uint64_t method_names_ptr); -extern void promise_batch_action_delete_key(uint64_t promise_index, uint64_t public_key_len, uint64_t public_key_ptr); -extern void promise_batch_action_delete_account(uint64_t promise_index, uint64_t beneficiary_id_len, uint64_t beneficiary_id_ptr); -extern void promise_batch_action_function_call_weight(uint64_t promise_index, uint64_t function_name_len, uint64_t function_name_ptr, uint64_t arguments_len, uint64_t arguments_ptr, uint64_t amount_ptr, uint64_t gas, uint64_t weight); -// ####################### -// # Promise API results # -// ####################### -extern uint64_t promise_results_count(void); -extern uint64_t promise_result(uint64_t result_idx, uint64_t register_id); -extern void promise_return(uint64_t promise_idx); -// ############### -// # Storage API # -// ############### -extern uint64_t storage_write(uint64_t key_len, uint64_t key_ptr, uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t storage_read(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_remove(uint64_t key_len, uint64_t key_ptr, uint64_t register_id); -extern uint64_t storage_has_key(uint64_t key_len, uint64_t key_ptr); -// ################# -// # Validator API # -// ################# -extern void validator_stake(uint64_t account_id_len, uint64_t account_id_ptr, uint64_t stake_ptr); -extern void validator_total_stake(uint64_t stake_ptr); -// ############# -// # Alt BN128 # -// ############# -#ifdef NIGHTLY -extern void alt_bn128_g1_multiexp(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern void alt_bn128_g1_sum(uint64_t value_len, uint64_t value_ptr, uint64_t register_id); -extern uint64_t alt_bn128_pairing_check(uint64_t value_len, uint64_t value_ptr); -#endif - -static uint8_t* JS_Uint8Array_to_C(JSContext *ctx, JSValue array, size_t *len) { - uint8_t *ptr; - JSValue buffer; - size_t pbyte_offset, psize, pbytes_per_element = 0; - - buffer = JS_GetTypedArrayBuffer(ctx, array, &pbyte_offset, len, &pbytes_per_element); - if (JS_IsException(buffer) || pbytes_per_element != 1) { - return NULL; - } - ptr = JS_GetArrayBuffer(ctx, &psize, buffer); - if (ptr == NULL) { - return NULL; - } - return ptr + pbyte_offset; -} - -static JSValue near_read_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data; - uint64_t data_len; - JSValue arraybuffer, ret; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_len = register_len(register_id); - if (data_len != UINT64_MAX) { - data = malloc(data_len); - read_register(register_id, (uint64_t)data); - arraybuffer = JS_NewArrayBuffer(ctx, data, (size_t)data_len, NULL, NULL, TRUE); - return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); - } else { - return JS_UNDEFINED; - } -} - -static JSValue near_register_len(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id, len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - len = register_len(register_id); - return JS_NewBigUint64(ctx, len); -} - -static JSValue near_write_register(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - data_ptr = JS_Uint8Array_to_C(ctx, argv[1], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - - write_register(register_id, data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_current_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - current_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_signer_account_pk(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - signer_account_pk(register_id); - return JS_UNDEFINED; -} - -static JSValue near_predecessor_account_id(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - predecessor_account_id(register_id); - return JS_UNDEFINED; -} - -static JSValue near_input(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - input(register_id); - return JS_UNDEFINED; -} - -static JSValue near_block_index(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_index(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_block_timestamp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = block_timestamp(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_epoch_height(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = epoch_height(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_storage_usage(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = storage_usage(); - return JS_NewBigUint64(ctx, value); -} - -// ptr[0] ptr[1] is little-endian u128. -static JSValue u128_to_quickjs(JSContext *ctx, uint64_t* ptr) { - JSValue value; - bf_t* bn; - bf_t b; - - value = JS_NewBigInt(ctx); - bn = JS_GetBigInt(value); - // from ptr[] to bn - // high 64 bits - bf_set_ui(bn, ptr[1]); - bf_mul_2exp(bn, 64, BF_PREC_INF, BF_RNDZ); - // low 64 bits - bf_init(bn->ctx, &b); - bf_set_ui(&b, ptr[0]); - bf_add(bn, bn, &b, BF_PREC_INF, BF_RNDZ); - bf_delete(&b); - - return value; -} - -static int quickjs_bigint_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - bf_t* a; - bf_t q, r, b, one, u128max; - a = JS_GetBigInt(val); - bf_init(a->ctx, &u128max); - bf_set_ui(&u128max, 1); - bf_mul_2exp(&u128max, 128, BF_PREC_INF, BF_RNDZ); - if (bf_cmp_le(&u128max, a)) { - return 1; - } - bf_init(a->ctx, &q); - bf_init(a->ctx, &r); - bf_init(a->ctx, &b); - bf_init(a->ctx, &one); - bf_set_ui(&b, UINT64_MAX); - bf_set_ui(&one, 1); - bf_add(&b, &b, &one, BF_PREC_INF, BF_RNDZ); - bf_divrem(&q, &r, a, &b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); - - bf_get_uint64(ptr, &r); - bf_get_uint64(ptr+1, &q); - return 0; -} - -static int quickjs_int_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_ToUint64Ext(ctx, ptr, val) < 0) { - return 1; - } - ptr[1] = 0; - return 0; -} - -static int quickjs_to_u128(JSContext *ctx, JSValueConst val, uint64_t* ptr) { - if (JS_IsBigInt(ctx, val)) - return quickjs_bigint_to_u128(ctx, val, ptr); - else { - return quickjs_int_to_u128(ctx, val, ptr); - } -} - -static JSValue near_account_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_account_locked_balance(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - account_locked_balance((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_attached_deposit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t ptr[2]; - - attached_deposit((uint64_t)ptr); - return u128_to_quickjs(ctx, ptr); -} - -static JSValue near_prepaid_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = prepaid_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_used_gas(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = used_gas(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_random_seed(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - - if (JS_ToUint64Ext(ctx, ®ister_id, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - random_seed(register_id); - return JS_UNDEFINED; -} - -static JSValue near_sha256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - sha256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak256(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - keccak256(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_keccak512(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - keccak512(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ripemd160(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - ripemd160(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_ecrecover(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t malleability_flag, v, register_id, result; - uint8_t *hash_ptr, *sig_ptr; - size_t hash_len, sign_len; - - hash_ptr = JS_Uint8Array_to_C(ctx, argv[0], &hash_len); - if (hash_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for hash"); - } - sig_ptr = JS_Uint8Array_to_C(ctx, argv[1], &sign_len); - if (sig_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for sig"); - } - if (JS_ToUint64Ext(ctx, &malleability_flag, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for malleability_flag"); - } - if (JS_ToUint64Ext(ctx, &v, argv[3]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for v"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - result = ecrecover(hash_len, (uint64_t)hash_ptr, sign_len, (uint64_t)sig_ptr, malleability_flag, v, register_id); - return JS_NewBigUint64(ctx, result); -} - -static JSValue near_value_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *value_ptr; - size_t value_len; - - value_ptr = JS_Uint8Array_to_C(ctx, argv[0], &value_len); - if (value_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); - } - value_return(value_len, (uint64_t)(value_ptr)); - return JS_UNDEFINED; -} - -static JSValue near_panic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - if (argc == 1) { - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - panic_utf8(data_len, (uint64_t)data_ptr); - } else { - panic(); - } - return JS_UNDEFINED; -} - -static JSValue near_panic_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - panic_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *data_ptr; - size_t data_len; - - data_ptr = JS_ToCStringLen(ctx, &data_len, argv[0]); - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf8(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - log_utf8(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_log_utf16(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for message"); - } - - log_utf16(data_len, (uint64_t)data_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr, *method_name_ptr; - uint8_t *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_create(account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr, *method_name_ptr; - uint8_t *arguments_ptr; - size_t account_id_len, method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas, ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[2]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[3], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[4], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - - ret = promise_then(promise_index, account_id_len, (uint64_t)account_id_ptr, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_and(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx_ptr[argc], ret; - - for(int i = 0; i < argc; i++) { - if (JS_ToUint64Ext(ctx, &promise_idx_ptr[i], argv[i]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_id"); - } - } - ret = promise_and((uint64_t)promise_idx_ptr, argc); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - ret = promise_batch_create(account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *account_id_ptr; - size_t account_id_len; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[1]); - ret = promise_batch_then(promise_index, account_id_len, (uint64_t)account_id_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_batch_action_create_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - promise_batch_action_create_account(promise_index); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_deploy_contract(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *code_ptr; - size_t code_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - code_ptr = JS_Uint8Array_to_C(ctx, argv[1], &code_len); - if (code_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for code"); - } - promise_batch_action_deploy_contract(promise_index, code_len, (uint64_t)code_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr; - uint8_t *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_Uint8Array_to_C(ctx, argv[2], &arguments_len); - if (arguments_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for arguments"); - } - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - promise_batch_action_function_call(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_transfer(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; // amount is u128 - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - promise_batch_action_transfer(promise_index, (uint64_t)amount_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint64_t amount_ptr[2]; - uint8_t *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - if (quickjs_to_u128(ctx, argv[1], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[2], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - - promise_batch_action_stake(promise_index, (uint64_t)amount_ptr, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_full_access(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *public_key_ptr; - size_t public_key_len; - uint64_t nonce; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - promise_batch_action_add_key_with_full_access(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_add_key_with_function_call(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *receiver_id_ptr, *method_names_ptr; - uint8_t *public_key_ptr; - size_t public_key_len, receiver_id_len, method_names_len; - uint64_t nonce, allowance_ptr[2]; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - if (JS_ToUint64Ext(ctx, &nonce, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for nonce"); - } - if (quickjs_to_u128(ctx, argv[3], allowance_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for allowance"); - } - receiver_id_ptr = JS_ToCStringLen(ctx, &receiver_id_len, argv[4]); - method_names_ptr = JS_ToCStringLen(ctx, &method_names_len, argv[5]); - - promise_batch_action_add_key_with_function_call(promise_index, public_key_len, (uint64_t)public_key_ptr, nonce, (uint64_t)allowance_ptr, receiver_id_len, (uint64_t)receiver_id_ptr, method_names_len, (uint64_t)method_names_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - uint8_t *public_key_ptr; - size_t public_key_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - public_key_ptr = JS_Uint8Array_to_C(ctx, argv[1], &public_key_len); - if (public_key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for public key"); - } - promise_batch_action_delete_key(promise_index, public_key_len, (uint64_t)public_key_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_function_call_weight(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *method_name_ptr, *arguments_ptr; - size_t method_name_len, arguments_len; - uint64_t amount_ptr[2]; // amount is u128 - uint64_t gas; - uint64_t weight; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - method_name_ptr = JS_ToCStringLen(ctx, &method_name_len, argv[1]); - arguments_ptr = JS_ToCStringLenRaw(ctx, &arguments_len, argv[2]); - if (quickjs_to_u128(ctx, argv[3], amount_ptr) != 0) { - return JS_ThrowTypeError(ctx, "Expect Uint128 for amount"); - } - if (JS_ToUint64Ext(ctx, &gas, argv[4]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for gas"); - } - if (JS_ToUint64Ext(ctx, &weight, argv[5]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for weight"); - } - promise_batch_action_function_call_weight(promise_index, method_name_len, (uint64_t)method_name_ptr, arguments_len, (uint64_t)arguments_ptr, (uint64_t)amount_ptr, gas, weight); - return JS_UNDEFINED; -} - -static JSValue near_promise_batch_action_delete_account(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_index; - const char *beneficiary_id_ptr; - size_t beneficiary_id_len; - - if (JS_ToUint64Ext(ctx, &promise_index, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_index"); - } - beneficiary_id_ptr = JS_ToCStringLen(ctx, &beneficiary_id_len, argv[1]); - promise_batch_action_delete_account(promise_index, beneficiary_id_len, (uint64_t)beneficiary_id_ptr); - return JS_UNDEFINED; -} - -static JSValue near_promise_results_count(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t value; - - value = promise_results_count(); - return JS_NewBigUint64(ctx, value); -} - -static JSValue near_promise_result(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t result_idx, register_id; - uint64_t ret; - - if (JS_ToUint64Ext(ctx, &result_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for result_idx"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = promise_result(result_idx, register_id); - - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_promise_return(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t promise_idx; - if (JS_ToUint64Ext(ctx, &promise_idx, argv[0]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for promise_idx"); - } - promise_return(promise_idx); - - return JS_UNDEFINED; -} - -static JSValue near_storage_write(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr, *value_ptr; - size_t key_len, value_len; - uint64_t register_id, ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - value_ptr = JS_Uint8Array_to_C(ctx, argv[1], &value_len); - if (value_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for value"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[2]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_write(key_len, (uint64_t)key_ptr, value_len, (uint64_t)value_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_read(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_read(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t register_id; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - ret = storage_remove(key_len, (uint64_t)key_ptr, register_id); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_storage_has_key(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *key_ptr; - size_t key_len; - uint64_t ret; - - key_ptr = JS_Uint8Array_to_C(ctx, argv[0], &key_len); - if (key_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for key"); - } - ret = storage_has_key(key_len, (uint64_t)key_ptr); - return JS_NewBigUint64(ctx, ret); -} - -static JSValue near_validator_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - const char *account_id_ptr; - size_t account_id_len; - uint64_t stake_ptr[2]; - - account_id_ptr = JS_ToCStringLen(ctx, &account_id_len, argv[0]); - validator_stake(account_id_len, (uint64_t)account_id_ptr, (uint64_t)stake_ptr); - - return u128_to_quickjs(ctx, stake_ptr); -} - -static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t stake_ptr[2]; - - validator_total_stake((uint64_t)stake_ptr); - return u128_to_quickjs(ctx, stake_ptr); -} - -#ifdef NIGHTLY -static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_multiexp(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_g1_sum(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint64_t register_id; - uint8_t *data_ptr; - size_t data_len; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - if (JS_ToUint64Ext(ctx, ®ister_id, argv[1]) < 0) { - return JS_ThrowTypeError(ctx, "Expect Uint64 for register_id"); - } - - alt_bn128_g1_sum(data_len, (uint64_t)data_ptr, register_id); - return JS_UNDEFINED; -} - -static JSValue near_alt_bn128_pairing_check(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) -{ - uint8_t *data_ptr; - size_t data_len; - uint64_t ret; - - data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); - if (data_ptr == NULL) { - return JS_ThrowTypeError(ctx, "Expect Uint8Array for data"); - } - ret = alt_bn128_pairing_check(data_len, (uint64_t)data_ptr); - return JS_NewBigUint64(ctx, ret); -} -#endif - -static void js_add_near_host_functions(JSContext* ctx) { - JSValue global_obj, env; - - global_obj = JS_GetGlobalObject(ctx); - env = JS_NewObject(ctx); - - JS_SetPropertyStr(ctx, env, "read_register", JS_NewCFunction(ctx, near_read_register, "read_register", 1)); - JS_SetPropertyStr(ctx, env, "register_len", JS_NewCFunction(ctx, near_register_len, "register_len", 1)); - JS_SetPropertyStr(ctx, env, "write_register", JS_NewCFunction(ctx, near_write_register, "write_register", 2)); - JS_SetPropertyStr(ctx, env, "current_account_id", JS_NewCFunction(ctx, near_current_account_id, "current_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_id", JS_NewCFunction(ctx, near_signer_account_id, "signer_account_id", 1)); - JS_SetPropertyStr(ctx, env, "signer_account_pk", JS_NewCFunction(ctx, near_signer_account_pk, "signer_account_pk", 1)); - JS_SetPropertyStr(ctx, env, "predecessor_account_id", JS_NewCFunction(ctx, near_predecessor_account_id, "predecessor_account_id", 1)); - JS_SetPropertyStr(ctx, env, "input", JS_NewCFunction(ctx, near_input, "input", 1)); - JS_SetPropertyStr(ctx, env, "block_index", JS_NewCFunction(ctx, near_block_index, "block_index", 0)); - JS_SetPropertyStr(ctx, env, "block_timestamp", JS_NewCFunction(ctx, near_block_timestamp, "block_timestamp", 0)); - JS_SetPropertyStr(ctx, env, "epoch_height", JS_NewCFunction(ctx, near_epoch_height, "epoch_height", 0)); - JS_SetPropertyStr(ctx, env, "storage_usage", JS_NewCFunction(ctx, near_storage_usage, "storage_usage", 0)); - JS_SetPropertyStr(ctx, env, "account_balance", JS_NewCFunction(ctx, near_account_balance, "account_balance", 0)); - JS_SetPropertyStr(ctx, env, "account_locked_balance", JS_NewCFunction(ctx, near_account_locked_balance, "account_locked_balance", 0)); - JS_SetPropertyStr(ctx, env, "attached_deposit", JS_NewCFunction(ctx, near_attached_deposit, "attached_deposit", 0)); - JS_SetPropertyStr(ctx, env, "prepaid_gas", JS_NewCFunction(ctx, near_prepaid_gas, "prepaid_gas", 0)); - JS_SetPropertyStr(ctx, env, "used_gas", JS_NewCFunction(ctx, near_used_gas, "used_gas", 0)); - JS_SetPropertyStr(ctx, env, "random_seed", JS_NewCFunction(ctx, near_random_seed, "random_seed", 1)); - JS_SetPropertyStr(ctx, env, "sha256", JS_NewCFunction(ctx, near_sha256, "sha256", 2)); - JS_SetPropertyStr(ctx, env, "keccak256", JS_NewCFunction(ctx, near_keccak256, "keccak256", 2)); - JS_SetPropertyStr(ctx, env, "keccak512", JS_NewCFunction(ctx, near_keccak512, "keccak512", 2)); - JS_SetPropertyStr(ctx, env, "ripemd160", JS_NewCFunction(ctx, near_ripemd160, "ripemd160", 2)); - JS_SetPropertyStr(ctx, env, "ecrecover", JS_NewCFunction(ctx, near_ecrecover, "ecrecover", 5)); - JS_SetPropertyStr(ctx, env, "value_return", JS_NewCFunction(ctx, near_value_return, "value_return", 1)); - JS_SetPropertyStr(ctx, env, "panic", JS_NewCFunction(ctx, near_panic, "panic", 1)); - JS_SetPropertyStr(ctx, env, "panic_utf8", JS_NewCFunction(ctx, near_panic_utf8, "panic_utf8", 1)); - JS_SetPropertyStr(ctx, env, "log", JS_NewCFunction(ctx, near_log, "log", 1)); - JS_SetPropertyStr(ctx, env, "log_utf8", JS_NewCFunction(ctx, near_log_utf8, "log_ut8", 1)); - JS_SetPropertyStr(ctx, env, "log_utf16", JS_NewCFunction(ctx, near_log_utf16, "log_utf16", 1)); - JS_SetPropertyStr(ctx, env, "promise_create", JS_NewCFunction(ctx, near_promise_create, "promise_create", 5)); - JS_SetPropertyStr(ctx, env, "promise_then", JS_NewCFunction(ctx, near_promise_then, "promise_then", 6)); - JS_SetPropertyStr(ctx, env, "promise_and", JS_NewCFunction(ctx, near_promise_and, "promise_and", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_create", JS_NewCFunction(ctx, near_promise_batch_create, "promise_batch_create", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_then", JS_NewCFunction(ctx, near_promise_batch_then, "promise_batch_then", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_create_account", JS_NewCFunction(ctx, near_promise_batch_action_create_account, "promise_batch_action_create_account", 1)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_deploy_contract", JS_NewCFunction(ctx, near_promise_batch_action_deploy_contract, "promise_batch_action_deploy_contract", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call", JS_NewCFunction(ctx, near_promise_batch_action_function_call, "promise_batch_action_function_call", 5)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_transfer", JS_NewCFunction(ctx, near_promise_batch_action_transfer, "promise_batch_action_transfer", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_stake", JS_NewCFunction(ctx, near_promise_batch_action_stake, "promise_batch_action_stake", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_full_access", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_full_access, "promise_batch_action_add_key_with_full_access", 3)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_add_key_with_function_call", JS_NewCFunction(ctx, near_promise_batch_action_add_key_with_function_call, "promise_batch_action_add_key_with_function_call", 6)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_key", JS_NewCFunction(ctx, near_promise_batch_action_delete_key, "promise_batch_action_delete_key", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_delete_account", JS_NewCFunction(ctx, near_promise_batch_action_delete_account, "promise_batch_action_delete_account", 2)); - JS_SetPropertyStr(ctx, env, "promise_batch_action_function_call_weight", JS_NewCFunction(ctx, near_promise_batch_action_function_call_weight, "promise_batch_action_function_call_weight", 6)); - JS_SetPropertyStr(ctx, env, "promise_results_count", JS_NewCFunction(ctx, near_promise_results_count, "promise_results_count", 0)); - JS_SetPropertyStr(ctx, env, "promise_result", JS_NewCFunction(ctx, near_promise_result, "promise_result", 2)); - JS_SetPropertyStr(ctx, env, "promise_return", JS_NewCFunction(ctx, near_promise_return, "promise_return", 1)); - JS_SetPropertyStr(ctx, env, "storage_write", JS_NewCFunction(ctx, near_storage_write, "storage_write", 2)); - JS_SetPropertyStr(ctx, env, "storage_read", JS_NewCFunction(ctx, near_storage_read, "storage_read", 2)); - JS_SetPropertyStr(ctx, env, "storage_remove", JS_NewCFunction(ctx, near_storage_remove, "storage_remove", 2)); - JS_SetPropertyStr(ctx, env, "storage_has_key", JS_NewCFunction(ctx, near_storage_has_key, "storage_has_key", 2)); - JS_SetPropertyStr(ctx, env, "validator_stake", JS_NewCFunction(ctx, near_validator_stake, "validator_stake", 2)); - JS_SetPropertyStr(ctx, env, "validator_total_stake", JS_NewCFunction(ctx, near_validator_total_stake, "validator_total_stake", 1)); - #ifdef NIGHTLY - // as of Jun 24, 2022, alt_bn128 is not a nightly protocol feature any more. It's part of protocol version 55. But, testnet -// is at protocol version 54 and mainnet is at protocol version 53. We'll enable and add alt_bn128 as they in testnet. - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_multiexp", JS_NewCFunction(ctx, near_alt_bn128_g1_multiexp, "alt_bn128_g1_multiexp", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_g1_sum", JS_NewCFunction(ctx, near_alt_bn128_g1_sum, "alt_bn128_g1_sum", 2)); - JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); - #endif - - JS_SetPropertyStr(ctx, global_obj, "env", env); -} - -JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, - int argc, JSValueConst *argv); - -void _start() {} - -#include "methods.h" From 78ed2a687ef26e958a9d3497bd5f33ce85e2ce74 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 23 Nov 2022 15:20:47 +0800 Subject: [PATCH 05/24] resolve conflict --- src/api.ts | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/api.ts b/src/api.ts index 06f3e8ca6..05419c2c0 100644 --- a/src/api.ts +++ b/src/api.ts @@ -673,58 +673,42 @@ export function promiseReturn(promiseIndex: PromiseIndex): void { env.promise_return(promiseIndex as unknown as bigint); } -<<<<<<< HEAD -export function sha256(value: Uint8Array): Uint8Array { -======= /** * Returns sha256 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export function sha256(value: Bytes): Bytes { ->>>>>>> develop +export function sha256(value: Uint8Array): Uint8Array { env.sha256(value, 0); return env.read_register(0); } -<<<<<<< HEAD -export function keccak256(value: Uint8Array): Uint8Array { -======= /** * Returns keccak256 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export function keccak256(value: Bytes): Bytes { ->>>>>>> develop +export function keccak256(value: Uint8Array): Uint8Array { env.keccak256(value, 0); return env.read_register(0); } -<<<<<<< HEAD -export function keccak512(value: Uint8Array): Uint8Array { -======= /** * Returns keccak512 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export function keccak512(value: Bytes): Bytes { ->>>>>>> develop +export function keccak512(value: Uint8Array): Uint8Array { env.keccak512(value, 0); return env.read_register(0); } -<<<<<<< HEAD -export function ripemd160(value: Uint8Array): Uint8Array { -======= /** * Returns ripemd160 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export function ripemd160(value: Bytes): Bytes { ->>>>>>> develop +export function ripemd160(value: Uint8Array): Uint8Array { env.ripemd160(value, 0); return env.read_register(0); } From c1336a5500bf1812da8a468e91da6ce2bc075667 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 23 Nov 2022 16:30:01 +0800 Subject: [PATCH 06/24] strictly different from uint8array and string, fix near-bindgen and utils --- lib/api.d.ts | 76 ++++++++++++++++---------------- lib/api.js | 8 ++-- lib/near-bindgen.d.ts | 4 +- lib/near-bindgen.js | 10 ++--- lib/promise.d.ts | 20 ++++----- lib/types/collections.d.ts | 6 +-- lib/types/public_key.d.ts | 5 +-- lib/types/public_key.js | 10 ++--- lib/utils.d.ts | 36 ++++++++------- lib/utils.js | 63 +++++++++++++++----------- src/near-bindgen.ts | 24 +++++----- src/promise.ts | 14 +++--- src/types/collections.ts | 6 +-- src/types/public_key.ts | 16 +++---- src/utils.ts | 90 +++++++++++++++++++------------------- 15 files changed, 201 insertions(+), 187 deletions(-) diff --git a/lib/api.d.ts b/lib/api.d.ts index 04d6ae2bf..d905af59d 100644 --- a/lib/api.d.ts +++ b/lib/api.d.ts @@ -1,4 +1,4 @@ -import { Bytes, NearAmount, PromiseIndex } from "./utils"; +import { NearAmount, PromiseIndex } from "./utils"; import { GasWeight } from "./types"; /** * Logs parameters in the NEAR WASM virtual machine. @@ -10,21 +10,21 @@ export declare function log(...params: unknown[]): void; * Returns the account ID of the account that signed the transaction. * Can only be called in a call or initialize function. */ -export declare function signerAccountId(): Bytes; +export declare function signerAccountId(): string; /** * Returns the public key of the account that signed the transaction. * Can only be called in a call or initialize function. */ -export declare function signerAccountPk(): Bytes; +export declare function signerAccountPk(): Uint8Array; /** * Returns the account ID of the account that called the function. * Can only be called in a call or initialize function. */ -export declare function predecessorAccountId(): Bytes; +export declare function predecessorAccountId(): string; /** * Returns the account ID of the current contract - the contract that is being executed. */ -export declare function currentAccountId(): Bytes; +export declare function currentAccountId(): string; /** * Returns the current block index. */ @@ -67,17 +67,17 @@ export declare function accountLockedBalance(): bigint; * * @param key - The key to read from storage. */ -export declare function storageRead(key: Bytes): Bytes | null; +export declare function storageRead(key: Uint8Array): Uint8Array | null; /** * Checks for the existance of a value under the provided key in NEAR storage. * * @param key - The key to check for in storage. */ -export declare function storageHasKey(key: Bytes): boolean; +export declare function storageHasKey(key: Uint8Array): boolean; /** * Get the last written or removed value from NEAR storage. */ -export declare function storageGetEvicted(): Bytes; +export declare function storageGetEvicted(): Uint8Array; /** * Returns the current accounts NEAR storage usage. */ @@ -88,13 +88,13 @@ export declare function storageUsage(): bigint; * @param key - The key under which to store the value. * @param value - The value to store. */ -export declare function storageWrite(key: Bytes, value: Bytes): boolean; +export declare function storageWrite(key: Uint8Array, value: Uint8Array): boolean; /** * Removes the value of the provided key from NEAR storage. * * @param key - The key to be removed. */ -export declare function storageRemove(key: Bytes): boolean; +export declare function storageRemove(key: Uint8Array): boolean; /** * Returns the cost of storing 0 Byte on NEAR storage. */ @@ -102,17 +102,17 @@ export declare function storageByteCost(): bigint; /** * Returns the arguments passed to the current smart contract call. */ -export declare function input(): Bytes; +export declare function input(): Uint8Array; /** * Returns the value from the NEAR WASM virtual machine. * * @param value - The value to return. */ -export declare function valueReturn(value: Bytes): void; +export declare function valueReturn(value: Uint8Array): void; /** * Returns a random string of bytes. */ -export declare function randomSeed(): Bytes; +export declare function randomSeed(): Uint8Array; /** * Create a NEAR promise call to a contract on the blockchain. * @@ -122,7 +122,7 @@ export declare function randomSeed(): Bytes; * @param amount - The amount of NEAR attached to the call. * @param gas - The amount of Gas attached to the call. */ -export declare function promiseCreate(accountId: Bytes, methodName: Bytes, args: Bytes, amount: NearAmount, gas: NearAmount): PromiseIndex; +export declare function promiseCreate(accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; /** * Attach a callback NEAR promise to be executed after a provided promise. * @@ -133,7 +133,7 @@ export declare function promiseCreate(accountId: Bytes, methodName: Bytes, args: * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export declare function promiseThen(promiseIndex: PromiseIndex, accountId: Bytes, methodName: Bytes, args: Bytes, amount: NearAmount, gas: NearAmount): PromiseIndex; +export declare function promiseThen(promiseIndex: PromiseIndex, accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; /** * Join an arbitrary array of NEAR promises. * @@ -145,14 +145,14 @@ export declare function promiseAnd(...promiseIndexes: PromiseIndex[]): PromiseIn * * @param accountId - The account ID of the target contract. */ -export declare function promiseBatchCreate(accountId: Bytes): PromiseIndex; +export declare function promiseBatchCreate(accountId: string): PromiseIndex; /** * Attach a callback NEAR promise to a batch of NEAR promise actions. * * @param promiseIndex - The NEAR promise index of the batch. * @param accountId - The account ID of the target contract. */ -export declare function promiseBatchThen(promiseIndex: PromiseIndex, accountId: Bytes): PromiseIndex; +export declare function promiseBatchThen(promiseIndex: PromiseIndex, accountId: string): PromiseIndex; /** * Attach a create account promise action to the NEAR promise index with the provided promise index. * @@ -165,7 +165,7 @@ export declare function promiseBatchActionCreateAccount(promiseIndex: PromiseInd * @param promiseIndex - The index of the promise to attach a deploy contract action to. * @param code - The WASM byte code of the contract to be deployed. */ -export declare function promiseBatchActionDeployContract(promiseIndex: PromiseIndex, code: Bytes): void; +export declare function promiseBatchActionDeployContract(promiseIndex: PromiseIndex, code: Uint8Array): void; /** * Attach a function call promise action to the NEAR promise index with the provided promise index. * @@ -175,7 +175,7 @@ export declare function promiseBatchActionDeployContract(promiseIndex: PromiseIn * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export declare function promiseBatchActionFunctionCall(promiseIndex: PromiseIndex, methodName: Bytes, args: Bytes, amount: NearAmount, gas: NearAmount): void; +export declare function promiseBatchActionFunctionCall(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): void; /** * Attach a transfer promise action to the NEAR promise index with the provided promise index. * @@ -190,7 +190,7 @@ export declare function promiseBatchActionTransfer(promiseIndex: PromiseIndex, a * @param amount - The amount of NEAR to stake. * @param publicKey - The public key with which to stake. */ -export declare function promiseBatchActionStake(promiseIndex: PromiseIndex, amount: NearAmount, publicKey: Bytes): void; +export declare function promiseBatchActionStake(promiseIndex: PromiseIndex, amount: NearAmount, publicKey: Uint8Array): void; /** * Attach a add full access key promise action to the NEAR promise index with the provided promise index. * @@ -198,7 +198,7 @@ export declare function promiseBatchActionStake(promiseIndex: PromiseIndex, amou * @param publicKey - The public key to add as a full access key. * @param nonce - The nonce to use. */ -export declare function promiseBatchActionAddKeyWithFullAccess(promiseIndex: PromiseIndex, publicKey: Bytes, nonce: number | bigint): void; +export declare function promiseBatchActionAddKeyWithFullAccess(promiseIndex: PromiseIndex, publicKey: Uint8Array, nonce: number | bigint): void; /** * Attach a add access key promise action to the NEAR promise index with the provided promise index. * @@ -209,21 +209,21 @@ export declare function promiseBatchActionAddKeyWithFullAccess(promiseIndex: Pro * @param receiverId - The account ID of the receiver. * @param methodNames - The names of the method to allow the key for. */ -export declare function promiseBatchActionAddKeyWithFunctionCall(promiseIndex: PromiseIndex, publicKey: Bytes, nonce: number | bigint, allowance: NearAmount, receiverId: Bytes, methodNames: Bytes): void; +export declare function promiseBatchActionAddKeyWithFunctionCall(promiseIndex: PromiseIndex, publicKey: Uint8Array, nonce: number | bigint, allowance: NearAmount, receiverId: string, methodNames: string): void; /** * Attach a delete key promise action to the NEAR promise index with the provided promise index. * * @param promiseIndex - The index of the promise to attach a delete key action to. * @param publicKey - The public key to delete. */ -export declare function promiseBatchActionDeleteKey(promiseIndex: PromiseIndex, publicKey: Bytes): void; +export declare function promiseBatchActionDeleteKey(promiseIndex: PromiseIndex, publicKey: Uint8Array): void; /** * Attach a delete account promise action to the NEAR promise index with the provided promise index. * * @param promiseIndex - The index of the promise to attach a delete account action to. * @param beneficiaryId - The account ID of the beneficiary - the account that receives the remaining amount of NEAR. */ -export declare function promiseBatchActionDeleteAccount(promiseIndex: PromiseIndex, beneficiaryId: Bytes): void; +export declare function promiseBatchActionDeleteAccount(promiseIndex: PromiseIndex, beneficiaryId: string): void; /** * Attach a function call with weight promise action to the NEAR promise index with the provided promise index. * @@ -234,7 +234,7 @@ export declare function promiseBatchActionDeleteAccount(promiseIndex: PromiseInd * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ -export declare function promiseBatchActionFunctionCallWeight(promiseIndex: PromiseIndex, methodName: Bytes, args: Bytes, amount: NearAmount, gas: NearAmount, weight: GasWeight): void; +export declare function promiseBatchActionFunctionCallWeight(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount, weight: GasWeight): void; /** * The number of promise results available. */ @@ -244,7 +244,7 @@ export declare function promiseResultsCount(): bigint; * * @param promiseIndex - The index of the promise to return the result for. */ -export declare function promiseResult(promiseIndex: PromiseIndex): Bytes; +export declare function promiseResult(promiseIndex: PromiseIndex): Uint8Array; /** * Executes the promise in the NEAR WASM virtual machine. * @@ -256,25 +256,25 @@ export declare function promiseReturn(promiseIndex: PromiseIndex): void; * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export declare function sha256(value: Bytes): Bytes; +export declare function sha256(value: Uint8Array): Uint8Array; /** * Returns keccak256 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export declare function keccak256(value: Bytes): Bytes; +export declare function keccak256(value: Uint8Array): Uint8Array; /** * Returns keccak512 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export declare function keccak512(value: Bytes): Bytes; +export declare function keccak512(value: Uint8Array): Uint8Array; /** * Returns ripemd160 hash of given value * @param value - value to be hashed, in Bytes * @returns hash result in Bytes */ -export declare function ripemd160(value: Bytes): Bytes; +export declare function ripemd160(value: Uint8Array): Uint8Array; /** * Recovers an ECDSA signer address from a 32-byte message hash and a corresponding * signature along with v recovery byte. Takes in an additional flag to check for @@ -286,28 +286,28 @@ export declare function ripemd160(value: Bytes): Bytes; * @param malleabilityFlag - whether to check malleability * @returns 64 bytes representing the public key if the recovery was successful. */ -export declare function ecrecover(hash: Bytes, sig: Bytes, v: number, malleabilityFlag: number): Bytes | null; +export declare function ecrecover(hash: Uint8Array, sig: Uint8Array, v: number, malleabilityFlag: number): Uint8Array | null; /** * Panic the transaction execution with given message * @param msg - panic message in raw bytes, which should be a valid UTF-8 sequence */ -export declare function panicUtf8(msg: Bytes): never; +export declare function panicUtf8(msg: Uint8Array): never; /** * Log the message in transaction logs * @param msg - message in raw bytes, which should be a valid UTF-8 sequence */ -export declare function logUtf8(msg: Bytes): void; +export declare function logUtf8(msg: Uint8Array): void; /** * Log the message in transaction logs * @param msg - message in raw bytes, which should be a valid UTF-16 sequence */ -export declare function logUtf16(msg: Bytes): void; +export declare function logUtf16(msg: Uint8Array): void; /** * Returns the number of staked NEAR of given validator, in yoctoNEAR * @param accountId - validator's AccountID * @returns - staked amount */ -export declare function validatorStake(accountId: Bytes): bigint; +export declare function validatorStake(accountId: string): bigint; /** * Returns the number of staked NEAR of all validators, in yoctoNEAR * @returns total staked amount @@ -325,7 +325,7 @@ export declare function validatorTotalStake(): bigint; * * @returns multi exp sum */ -export declare function altBn128G1Multiexp(value: Bytes): Bytes; +export declare function altBn128G1Multiexp(value: Uint8Array): Uint8Array; /** * Computes sum for signed g1 group elements on alt_bn128 curve \sum_i * (-1)^{sign_i} g_{1 i} should be equal result. @@ -338,7 +338,7 @@ export declare function altBn128G1Multiexp(value: Bytes): Bytes; * * @returns sum over Fq. */ -export declare function altBn128G1Sum(value: Bytes): Bytes; +export declare function altBn128G1Sum(value: Uint8Array): Uint8Array; /** * Computes pairing check on alt_bn128 curve. * \sum_i e(g_{1 i}, g_{2 i}) should be equal one (in additive notation), e(g1, g2) is Ate pairing @@ -354,4 +354,4 @@ export declare function altBn128G1Sum(value: Bytes): Bytes; * * @returns whether pairing check pass */ -export declare function altBn128PairingCheck(value: Bytes): boolean; +export declare function altBn128PairingCheck(value: Uint8Array): boolean; diff --git a/lib/api.js b/lib/api.js index 0c5b38caa..4178e3a63 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,4 +1,4 @@ -import { assert } from "./utils"; +import { assert, u8ArrayToLatin1, } from "./utils"; import { PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; const EVICTED_REGISTER = U64_MAX - 1n; @@ -25,7 +25,7 @@ export function log(...params) { */ export function signerAccountId() { env.signer_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** * Returns the public key of the account that signed the transaction. @@ -41,14 +41,14 @@ export function signerAccountPk() { */ export function predecessorAccountId() { env.predecessor_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** * Returns the account ID of the current contract - the contract that is being executed. */ export function currentAccountId() { env.current_account_id(0); - return env.read_register(0); + return u8ArrayToLatin1(env.read_register(0)); } /** * Returns the current block index. diff --git a/lib/near-bindgen.d.ts b/lib/near-bindgen.d.ts index f5eda6284..bf60f5292 100644 --- a/lib/near-bindgen.d.ts +++ b/lib/near-bindgen.d.ts @@ -54,8 +54,8 @@ export declare function middleware>(...middlewares: */ export declare function NearBindgen(options: { requireInit?: boolean; - serializer?(value: unknown): string; - deserializer?(value: string): unknown; + serializer?(value: unknown): Uint8Array; + deserializer?(value: Uint8Array): unknown; }): any; declare module "./" { /** diff --git a/lib/near-bindgen.js b/lib/near-bindgen.js index e6aa747a5..15fdbb6c1 100644 --- a/lib/near-bindgen.js +++ b/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize } from "./utils"; +import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1 } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * @@ -71,18 +71,18 @@ export function NearBindgen({ requireInit = false, serializer = serialize, deser return new target(); } static _getState() { - const rawState = near.storageRead("STATE"); + const rawState = near.storageRead(latin1ToU8Array("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave) { - near.storageWrite("STATE", this._serialize(objectToSave)); + near.storageWrite(latin1ToU8Array("STATE"), this._serialize(objectToSave)); } static _getArgs() { - return JSON.parse(near.input() || "{}"); + return JSON.parse(u8ArrayToLatin1(near.input()) || "{}"); } static _serialize(value, forReturn = false) { if (forReturn) { - return JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value); + return latin1ToU8Array(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value)); } return serializer(value); } diff --git a/lib/promise.d.ts b/lib/promise.d.ts index f02e701c6..aa47c2e27 100644 --- a/lib/promise.d.ts +++ b/lib/promise.d.ts @@ -1,4 +1,4 @@ -import { Bytes, PromiseIndex } from "./utils"; +import { PromiseIndex } from "./utils"; import { Balance, PublicKey, AccountId, Gas, GasWeight } from "./types"; import { Nonce } from "./types/primitives"; /** @@ -26,11 +26,11 @@ export declare class CreateAccount extends PromiseAction { * @extends {PromiseAction} */ export declare class DeployContract extends PromiseAction { - code: Bytes; + code: Uint8Array; /** * @param code - The code of the contract to be deployed. */ - constructor(code: Bytes); + constructor(code: Uint8Array); add(promiseIndex: PromiseIndex): void; } /** @@ -40,7 +40,7 @@ export declare class DeployContract extends PromiseAction { */ export declare class FunctionCall extends PromiseAction { functionName: string; - args: Bytes; + args: Uint8Array; amount: Balance; gas: Gas; /** @@ -49,7 +49,7 @@ export declare class FunctionCall extends PromiseAction { * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ - constructor(functionName: string, args: Bytes, amount: Balance, gas: Gas); + constructor(functionName: string, args: Uint8Array, amount: Balance, gas: Gas); add(promiseIndex: PromiseIndex): void; } /** @@ -59,7 +59,7 @@ export declare class FunctionCall extends PromiseAction { */ export declare class FunctionCallWeight extends PromiseAction { functionName: string; - args: Bytes; + args: Uint8Array; amount: Balance; gas: Gas; weight: GasWeight; @@ -70,7 +70,7 @@ export declare class FunctionCallWeight extends PromiseAction { * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ - constructor(functionName: string, args: Bytes, amount: Balance, gas: Gas, weight: GasWeight); + constructor(functionName: string, args: Uint8Array, amount: Balance, gas: Gas, weight: GasWeight); add(promiseIndex: PromiseIndex): void; } /** @@ -206,7 +206,7 @@ export declare class NearPromise { * * @param code - The code of the contract to be deployed. */ - deployContract(code: Bytes): NearPromise; + deployContract(code: Uint8Array): NearPromise; /** * Creates a function call promise action and adds it to the current promise. * @@ -215,7 +215,7 @@ export declare class NearPromise { * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ - functionCall(functionName: string, args: Bytes, amount: Balance, gas: Gas): NearPromise; + functionCall(functionName: string, args: Uint8Array, amount: Balance, gas: Gas): NearPromise; /** * Creates a function call weight promise action and adds it to the current promise. * @@ -225,7 +225,7 @@ export declare class NearPromise { * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ - functionCallWeight(functionName: string, args: Bytes, amount: Balance, gas: Gas, weight: GasWeight): NearPromise; + functionCallWeight(functionName: string, args: Uint8Array, amount: Balance, gas: Gas, weight: GasWeight): NearPromise; /** * Creates a transfer promise action and adds it to the current promise. * diff --git a/lib/types/collections.d.ts b/lib/types/collections.d.ts index 33c4f8395..c67d1724a 100644 --- a/lib/types/collections.d.ts +++ b/lib/types/collections.d.ts @@ -17,11 +17,11 @@ export interface GetOptions { * * @param valueToSerialize - The value that will be serialized - either the `DataType` or a unknown value. */ - serializer?(valueToSerialize: unknown): string; + serializer?(valueToSerialize: unknown): Uint8Array; /** * A deserializer function to customize the deserialization of values after reading from NEAR storage for this call. * - * @param valueToDeserialize - The string retrieved from NEAR storage to deserialize. + * @param valueToDeserialize - The Uint8Array retrieved from NEAR storage to deserialize. */ - deserializer?(valueToDeserialize: string): unknown; + deserializer?(valueToDeserialize: Uint8Array): unknown; } diff --git a/lib/types/public_key.d.ts b/lib/types/public_key.d.ts index 095729d4e..6b31d021b 100644 --- a/lib/types/public_key.d.ts +++ b/lib/types/public_key.d.ts @@ -1,4 +1,3 @@ -import { Bytes } from "../utils"; export declare enum CurveType { ED25519 = 0, SECP256K1 = 1 @@ -25,12 +24,12 @@ export declare class PublicKey { /** * The actual value of the public key. */ - data: Bytes; + data: Uint8Array; private type; /** * @param data - The string you want to create a PublicKey from. */ - constructor(data: Bytes); + constructor(data: Uint8Array); /** * The curve type of the public key. */ diff --git a/lib/types/public_key.js b/lib/types/public_key.js index 4fdaad34f..39f8859c6 100644 --- a/lib/types/public_key.js +++ b/lib/types/public_key.js @@ -1,5 +1,5 @@ -import { bytes } from "../utils"; import { base58 } from "@scure/base"; +import { u8ArrayConcat } from "../utils"; export var CurveType; (function (CurveType) { CurveType[CurveType["ED25519"] = 0] = "ED25519"; @@ -81,11 +81,11 @@ export class PublicKey { * @param data - The string you want to create a PublicKey from. */ constructor(data) { - const curveLenght = dataLength(data.charCodeAt(0)); + const curveLenght = dataLength(data[0]); if (data.length !== curveLenght + 1) { throw new InvalidLengthError(data.length, curveLenght + 1); } - this.type = getCurveType(data.charCodeAt(0)); + this.type = getCurveType(data[0]); this.data = data; } /** @@ -103,11 +103,11 @@ export class PublicKey { const [curve, keyData] = splitKeyTypeData(publicKeyString); let data; try { - data = bytes(base58.decode(keyData)); + data = base58.decode(keyData); } catch (error) { throw new Base58Error(error.message); } - return new PublicKey(`${String.fromCharCode(curve)}${data}`); + return new PublicKey(u8ArrayConcat(new Uint8Array([curve]), data)); } } diff --git a/lib/utils.d.ts b/lib/utils.d.ts index 21e2dd87d..351ecf140 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -1,8 +1,4 @@ import { GetOptions } from "./types/collections"; -/** - * A string containing byte characters. Can be safely used in NEAR calls. - */ -export declare type Bytes = string; declare enum PromiseIndexBrand { _ = -1 } @@ -20,15 +16,25 @@ export declare type NearAmount = number | bigint; export declare type Register = number | bigint; export declare const ERR_INCONSISTENT_STATE = "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?"; export declare const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; -export declare function u8ArrayToBytes(array: Uint8Array): Bytes; -export declare function bytesToU8Array(bytes: Bytes): Uint8Array; /** - * Accepts a string or Uint8Array and either checks for the validity of the string or converts the Uint8Array to Bytes. - * - * @param stringOrU8Array - The string or Uint8Array to be checked/transformed - * @returns Safe Bytes to be used in NEAR calls. + * Convert a Uint8Array to string, use Latin1 encoding + * @param array - Uint8Array to convert + * @returns result string + */ +export declare function u8ArrayToLatin1(array: Uint8Array): string; +/** + * Convert a Latin1 string to Uint8Array + * @param latin1 - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export declare function latin1ToU8Array(latin1: string): Uint8Array; +/** + * Concat two Uint8Array + * @param array1 + * @param array2 + * @returns the concatenation of two array */ -export declare function bytes(stringOrU8Array: string | Uint8Array): Bytes; +export declare function u8ArrayConcat(array1: Uint8Array, array2: Uint8Array): Uint8Array; /** * Asserts that the expression passed to the function is truthy, otherwise throws a new Error with the provided message. * @@ -39,10 +45,10 @@ export declare function assert(expression: unknown, message: string): asserts ex export declare type Mutable = { -readonly [P in keyof T]: T[P]; }; -export declare function getValueWithOptions(value: string, options?: Omit, "serializer">): DataType | null; -export declare function serializeValueWithOptions(value: DataType, { serializer }?: Pick, "serializer">): string; -export declare function serialize(valueToSerialize: unknown): string; -export declare function deserialize(valueToDeserialize: string): unknown; +export declare function getValueWithOptions(value: Uint8Array, options?: Omit, "serializer">): DataType | null; +export declare function serializeValueWithOptions(value: DataType, { serializer }?: Pick, "serializer">): Uint8Array; +export declare function serialize(valueToSerialize: unknown): Uint8Array; +export declare function deserialize(valueToDeserialize: Uint8Array): unknown; /** * Validates the Account ID according to the NEAR protocol * [Account ID rules](https://nomicon.io/DataStructures/Account#account-id-rules). diff --git a/lib/utils.js b/lib/utils.js index c20240d1c..acd958797 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,34 +12,45 @@ var TypeBrand; export const ERR_INCONSISTENT_STATE = "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?"; export const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; const ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/; -export function u8ArrayToBytes(array) { - return array.reduce((result, value) => `${result}${String.fromCharCode(value)}`, ""); -} -// TODO this function is a bit broken and the type can't be string -// TODO for more info: https://github.com/near/near-sdk-js/issues/78 -export function bytesToU8Array(bytes) { - return Uint8Array.from([...bytes].map((byte) => byte.charCodeAt(0))); -} /** - * Accepts a string or Uint8Array and either checks for the validity of the string or converts the Uint8Array to Bytes. - * - * @param stringOrU8Array - The string or Uint8Array to be checked/transformed - * @returns Safe Bytes to be used in NEAR calls. + * Convert a Uint8Array to string, use Latin1 encoding + * @param array - Uint8Array to convert + * @returns result string */ -export function bytes(stringOrU8Array) { - if (typeof stringOrU8Array === "string") { - return checkStringIsBytes(stringOrU8Array); +export function u8ArrayToLatin1(array) { + let ret = ""; + for (let e of array) { + ret += String.fromCharCode(e); } - if (stringOrU8Array instanceof Uint8Array) { - return u8ArrayToBytes(stringOrU8Array); + return ret; +} +/** + * Convert a Latin1 string to Uint8Array + * @param latin1 - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export function latin1ToU8Array(latin1) { + let ret = new Uint8Array(latin1.length); + for (let i = 0; i < latin1.length; i++) { + let code = latin1.charCodeAt(i); + if (code > 255) { + throw new Error(`string at index ${i}: ${latin1[i]} is not a valid latin1 char`); + } + ret[i] = code; } - throw new Error("bytes: expected string or Uint8Array"); + return ret; } -function checkStringIsBytes(value) { - [...value].forEach((character, index) => { - assert(character.charCodeAt(0) <= 255, `string ${value} at index ${index}: ${character} is not a valid byte`); - }); - return value; +/** + * Concat two Uint8Array + * @param array1 + * @param array2 + * @returns the concatenation of two array + */ +export function u8ArrayConcat(array1, array2) { + let mergedArray = new Uint8Array(array1.length + array2.length); + mergedArray.set(array1); + mergedArray.set(array2, array1.length); + return mergedArray; } /** * Asserts that the expression passed to the function is truthy, otherwise throws a new Error with the provided message. @@ -70,7 +81,7 @@ export function serializeValueWithOptions(value, { serializer } = { return serializer(value); } export function serialize(valueToSerialize) { - return JSON.stringify(valueToSerialize, function (key, value) { + return latin1ToU8Array(JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { value: value.toString(), @@ -86,10 +97,10 @@ export function serialize(valueToSerialize) { }; } return value; - }); + })); } export function deserialize(valueToDeserialize) { - return JSON.parse(valueToDeserialize, (_, value) => { + return JSON.parse(u8ArrayToLatin1(valueToDeserialize), (_, value) => { if (value !== null && typeof value === "object" && Object.keys(value).length === 2 && diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index c52392f88..3803ac7b5 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize } from "./utils"; +import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1 } from "./utils"; type EmptyParameterObject = Record; type AnyObject = Record; @@ -145,8 +145,8 @@ export function middleware>( */ export function NearBindgen(options: { requireInit?: boolean; - serializer?(value: unknown): string; - deserializer?(value: string): unknown; + serializer?(value: unknown): Uint8Array; + deserializer?(value: Uint8Array): unknown; // eslint-disable-next-line @typescript-eslint/no-explicit-any }): any; export function NearBindgen({ @@ -155,8 +155,8 @@ export function NearBindgen({ deserializer = deserialize, }: { requireInit?: boolean; - serializer?(value: unknown): string; - deserializer?(value: string): unknown; + serializer?(value: unknown): Uint8Array; + deserializer?(value: Uint8Array): unknown; }) { // eslint-disable-next-line @typescript-eslint/no-explicit-any return (target: T) => { @@ -166,29 +166,29 @@ export function NearBindgen({ } static _getState(): unknown | null { - const rawState = near.storageRead("STATE"); + const rawState = near.storageRead(latin1ToU8Array("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave: unknown): void { - near.storageWrite("STATE", this._serialize(objectToSave)); + near.storageWrite(latin1ToU8Array("STATE"), this._serialize(objectToSave)); } static _getArgs(): unknown { - return JSON.parse(near.input() || "{}"); + return JSON.parse(u8ArrayToLatin1(near.input()) || "{}"); } - static _serialize(value: unknown, forReturn = false): string { + static _serialize(value: unknown, forReturn = false): Uint8Array { if (forReturn) { - return JSON.stringify(value, (_, value) => + return latin1ToU8Array(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value - ); + )); } return serializer(value); } - static _deserialize(value: string): unknown { + static _deserialize(value: Uint8Array): unknown { return deserializer(value); } diff --git a/src/promise.ts b/src/promise.ts index 2cf333273..6bfaa4ba8 100644 --- a/src/promise.ts +++ b/src/promise.ts @@ -1,4 +1,4 @@ -import { assert, Bytes, PromiseIndex } from "./utils"; +import { assert, PromiseIndex } from "./utils"; import * as near from "./api"; import { Balance, PublicKey, AccountId, Gas, GasWeight } from "./types"; import { Nonce } from "./types/primitives"; @@ -35,7 +35,7 @@ export class DeployContract extends PromiseAction { /** * @param code - The code of the contract to be deployed. */ - constructor(public code: Bytes) { + constructor(public code: Uint8Array) { super(); } @@ -58,7 +58,7 @@ export class FunctionCall extends PromiseAction { */ constructor( public functionName: string, - public args: Bytes, + public args: Uint8Array, public amount: Balance, public gas: Gas ) { @@ -91,7 +91,7 @@ export class FunctionCallWeight extends PromiseAction { */ constructor( public functionName: string, - public args: Bytes, + public args: Uint8Array, public amount: Balance, public gas: Gas, public weight: GasWeight @@ -336,7 +336,7 @@ export class NearPromise { * * @param code - The code of the contract to be deployed. */ - deployContract(code: Bytes): NearPromise { + deployContract(code: Uint8Array): NearPromise { return this.addAction(new DeployContract(code)); } @@ -350,7 +350,7 @@ export class NearPromise { */ functionCall( functionName: string, - args: Bytes, + args: Uint8Array, amount: Balance, gas: Gas ): NearPromise { @@ -368,7 +368,7 @@ export class NearPromise { */ functionCallWeight( functionName: string, - args: Bytes, + args: Uint8Array, amount: Balance, gas: Gas, weight: GasWeight diff --git a/src/types/collections.ts b/src/types/collections.ts index 3c7211dc0..b48aab1e9 100644 --- a/src/types/collections.ts +++ b/src/types/collections.ts @@ -17,11 +17,11 @@ export interface GetOptions { * * @param valueToSerialize - The value that will be serialized - either the `DataType` or a unknown value. */ - serializer?(valueToSerialize: unknown): string; + serializer?(valueToSerialize: unknown): Uint8Array; /** * A deserializer function to customize the deserialization of values after reading from NEAR storage for this call. * - * @param valueToDeserialize - The string retrieved from NEAR storage to deserialize. + * @param valueToDeserialize - The Uint8Array retrieved from NEAR storage to deserialize. */ - deserializer?(valueToDeserialize: string): unknown; + deserializer?(valueToDeserialize: Uint8Array): unknown; } diff --git a/src/types/public_key.ts b/src/types/public_key.ts index 40d45873a..bb627a705 100644 --- a/src/types/public_key.ts +++ b/src/types/public_key.ts @@ -1,5 +1,5 @@ -import { Bytes, bytes } from "../utils"; import { base58 } from "@scure/base"; +import { u8ArrayConcat } from "../utils"; export enum CurveType { ED25519 = 0, @@ -82,20 +82,20 @@ export class PublicKey { /** * The actual value of the public key. */ - public data: Bytes; + public data: Uint8Array; private type: CurveType; /** * @param data - The string you want to create a PublicKey from. */ - constructor(data: Bytes) { - const curveLenght = dataLength(data.charCodeAt(0)); + constructor(data: Uint8Array) { + const curveLenght = dataLength(data[0]); if (data.length !== curveLenght + 1) { throw new InvalidLengthError(data.length, curveLenght + 1); } - this.type = getCurveType(data.charCodeAt(0)); + this.type = getCurveType(data[0]); this.data = data; } @@ -113,14 +113,14 @@ export class PublicKey { */ static fromString(publicKeyString: string) { const [curve, keyData] = splitKeyTypeData(publicKeyString); - let data: Bytes; + let data: Uint8Array; try { - data = bytes(base58.decode(keyData)); + data = base58.decode(keyData); } catch (error) { throw new Base58Error(error.message); } - return new PublicKey(`${String.fromCharCode(curve)}${data}`); + return new PublicKey(u8ArrayConcat(new Uint8Array([curve]), data)); } } diff --git a/src/utils.ts b/src/utils.ts index 49256caad..3571022ec 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,10 +1,5 @@ import { GetOptions } from "./types/collections"; -/** - * A string containing byte characters. Can be safely used in NEAR calls. - */ -export type Bytes = string; - // make PromiseIndex a nominal typing enum PromiseIndexBrand { _ = -1, @@ -35,46 +30,49 @@ export const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; const ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/; -export function u8ArrayToBytes(array: Uint8Array): Bytes { - return array.reduce( - (result, value) => `${result}${String.fromCharCode(value)}`, - "" - ); -} - -// TODO this function is a bit broken and the type can't be string -// TODO for more info: https://github.com/near/near-sdk-js/issues/78 -export function bytesToU8Array(bytes: Bytes): Uint8Array { - return Uint8Array.from([...bytes].map((byte) => byte.charCodeAt(0))); -} - /** - * Accepts a string or Uint8Array and either checks for the validity of the string or converts the Uint8Array to Bytes. - * - * @param stringOrU8Array - The string or Uint8Array to be checked/transformed - * @returns Safe Bytes to be used in NEAR calls. + * Convert a Uint8Array to string, use Latin1 encoding + * @param array - Uint8Array to convert + * @returns result string */ -export function bytes(stringOrU8Array: string | Uint8Array): Bytes { - if (typeof stringOrU8Array === "string") { - return checkStringIsBytes(stringOrU8Array); +export function u8ArrayToLatin1(array: Uint8Array): string { + let ret = ""; + for (let e of array) { + ret += String.fromCharCode(e); } + return ret; +} - if (stringOrU8Array instanceof Uint8Array) { - return u8ArrayToBytes(stringOrU8Array); +/** + * Convert a Latin1 string to Uint8Array + * @param latin1 - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export function latin1ToU8Array(latin1: string): Uint8Array { + let ret = new Uint8Array(latin1.length); + for (let i = 0; i < latin1.length; i++) { + let code = latin1.charCodeAt(i); + if (code > 255) { + throw new Error( + `string at index ${i}: ${latin1[i]} is not a valid latin1 char` + ); + } + ret[i] = code; } - - throw new Error("bytes: expected string or Uint8Array"); + return ret; } - -function checkStringIsBytes(value: string): string { - [...value].forEach((character, index) => { - assert( - character.charCodeAt(0) <= 255, - `string ${value} at index ${index}: ${character} is not a valid byte` - ); - }); - - return value; + +/** + * Concat two Uint8Array + * @param array1 + * @param array2 + * @returns the concatenation of two array + */ +export function u8ArrayConcat(array1: Uint8Array, array2: Uint8Array): Uint8Array { + let mergedArray = new Uint8Array(array1.length + array2.length); + mergedArray.set(array1); + mergedArray.set(array2, array1.length); + return mergedArray } /** @@ -95,7 +93,7 @@ export function assert( export type Mutable = { -readonly [P in keyof T]: T[P] }; export function getValueWithOptions( - value: string, + value: Uint8Array, options: Omit, "serializer"> = { deserializer: deserialize, } @@ -118,12 +116,12 @@ export function serializeValueWithOptions( { serializer }: Pick, "serializer"> = { serializer: serialize, } -): string { +): Uint8Array { return serializer(value); } -export function serialize(valueToSerialize: unknown): string { - return JSON.stringify(valueToSerialize, function (key, value) { +export function serialize(valueToSerialize: unknown): Uint8Array { + return latin1ToU8Array(JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { value: value.toString(), @@ -143,11 +141,11 @@ export function serialize(valueToSerialize: unknown): string { } return value; - }); + })); } -export function deserialize(valueToDeserialize: string): unknown { - return JSON.parse(valueToDeserialize, (_, value) => { +export function deserialize(valueToDeserialize: Uint8Array): unknown { + return JSON.parse(u8ArrayToLatin1(valueToDeserialize), (_, value) => { if ( value !== null && typeof value === "object" && From c49802abe7935effdf42582d78e68f6b37dc6128 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 29 Nov 2022 19:04:15 +0800 Subject: [PATCH 07/24] make collections use uint8array instead of bytes --- lib/collections/lookup-map.d.ts | 17 ++++----- lib/collections/lookup-map.js | 10 ++--- lib/collections/lookup-set.d.ts | 9 ++--- lib/collections/lookup-set.js | 12 +++--- lib/collections/unordered-map.d.ts | 23 ++++++----- lib/collections/unordered-map.js | 10 ++--- lib/collections/unordered-set.d.ts | 9 ++--- lib/collections/unordered-set.js | 24 ++++++------ lib/collections/vector.d.ts | 7 ++-- lib/collections/vector.js | 5 +-- src/collections/lookup-map.ts | 24 ++++++------ src/collections/lookup-set.ts | 25 ++++++++---- src/collections/unordered-map.ts | 39 +++++++++++-------- src/collections/unordered-set.ts | 59 +++++++++++++++++------------ src/collections/vector.ts | 12 +++--- src/near-bindgen.ts | 20 +++++++--- src/utils.ts | 61 ++++++++++++++++-------------- 17 files changed, 199 insertions(+), 167 deletions(-) diff --git a/lib/collections/lookup-map.d.ts b/lib/collections/lookup-map.d.ts index 4934e7b8d..bf6aa818d 100644 --- a/lib/collections/lookup-map.d.ts +++ b/lib/collections/lookup-map.d.ts @@ -1,34 +1,33 @@ import { GetOptions } from "../types/collections"; -import { Bytes } from "../utils"; /** * A lookup map that stores data in NEAR storage. */ export declare class LookupMap { - readonly keyPrefix: Bytes; + readonly keyPrefix: Uint8Array; /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(keyPrefix: Bytes); + constructor(keyPrefix: Uint8Array); /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. */ - containsKey(key: Bytes): boolean; + containsKey(key: Uint8Array): boolean; /** * Get the data stored at the provided key. * * @param key - The key at which to look for the data. * @param options - Options for retrieving the data. */ - get(key: Bytes, options?: Omit, "serializer">): DataType | null; + get(key: Uint8Array, options?: Omit, "serializer">): DataType | null; /** * Removes and retrieves the element with the provided key. * * @param key - The key at which to remove data. * @param options - Options for retrieving the data. */ - remove(key: Bytes, options?: Omit, "serializer">): DataType | null; + remove(key: Uint8Array, options?: Omit, "serializer">): DataType | null; /** * Store a new value at the provided key. * @@ -36,20 +35,20 @@ export declare class LookupMap { * @param newValue - The value to store in the collection. * @param options - Options for retrieving and storing the data. */ - set(key: Bytes, newValue: DataType, options?: GetOptions): DataType | null; + set(key: Uint8Array, newValue: DataType, options?: GetOptions): DataType | null; /** * Extends the current collection with the passed in array of key-value pairs. * * @param keyValuePairs - The key-value pairs to extend the collection with. * @param options - Options for storing the data. */ - extend(keyValuePairs: [Bytes, DataType][], options?: GetOptions): void; + extend(keyValuePairs: [Uint8Array, DataType][], options?: GetOptions): void; /** * Serialize the collection. * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string; + serialize(options?: Pick, "serializer">): Uint8Array; /** * Converts the deserialized data from storage to a JavaScript instance of the collection. * diff --git a/lib/collections/lookup-map.js b/lib/collections/lookup-map.js index ccfbd3b70..52ef69db0 100644 --- a/lib/collections/lookup-map.js +++ b/lib/collections/lookup-map.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { getValueWithOptions, serializeValueWithOptions, } from "../utils"; +import { getValueWithOptions, serializeValueWithOptions, u8ArrayConcat, } from "../utils"; /** * A lookup map that stores data in NEAR storage. */ @@ -16,7 +16,7 @@ export class LookupMap { * @param key - The value for which to check the presence. */ containsKey(key) { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); return near.storageHasKey(storageKey); } /** @@ -26,7 +26,7 @@ export class LookupMap { * @param options - Options for retrieving the data. */ get(key, options) { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); const value = near.storageRead(storageKey); return getValueWithOptions(value, options); } @@ -37,7 +37,7 @@ export class LookupMap { * @param options - Options for retrieving the data. */ remove(key, options) { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; } @@ -52,7 +52,7 @@ export class LookupMap { * @param options - Options for retrieving and storing the data. */ set(key, newValue, options) { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); const storageValue = serializeValueWithOptions(newValue, options); if (!near.storageWrite(storageKey, storageValue)) { return options?.defaultValue ?? null; diff --git a/lib/collections/lookup-set.d.ts b/lib/collections/lookup-set.d.ts index b5754f887..58a8c4d70 100644 --- a/lib/collections/lookup-set.d.ts +++ b/lib/collections/lookup-set.d.ts @@ -1,21 +1,20 @@ import { GetOptions } from "../types/collections"; -import { Bytes } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. */ export declare class LookupSet { - readonly keyPrefix: Bytes; + readonly keyPrefix: Uint8Array; /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(keyPrefix: Bytes); + constructor(keyPrefix: Uint8Array); /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. * @param options - Options for storing data. */ - contains(key: DataType, options?: Pick, "serializer">): boolean; + contains(key: Uint8Array, options?: Pick, "serializer">): boolean; /** * Returns true if the element was present in the set. * @@ -43,7 +42,7 @@ export declare class LookupSet { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string; + serialize(options?: Pick, "serializer">): Uint8Array; /** * Converts the deserialized data from storage to a JavaScript instance of the collection. * diff --git a/lib/collections/lookup-set.js b/lib/collections/lookup-set.js index b597f97b3..d257abb5a 100644 --- a/lib/collections/lookup-set.js +++ b/lib/collections/lookup-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { serializeValueWithOptions } from "../utils"; +import { serializeValueWithOptions, u8ArrayConcat } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. */ @@ -17,7 +17,7 @@ export class LookupSet { * @param options - Options for storing data. */ contains(key, options) { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); return near.storageHasKey(storageKey); } /** @@ -27,7 +27,8 @@ export class LookupSet { * @param options - Options for storing data. */ remove(key, options) { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); + ; return near.storageRemove(storageKey); } /** @@ -38,8 +39,9 @@ export class LookupSet { * @param options - Options for storing the data. */ set(key, options) { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return !near.storageWrite(storageKey, ""); + const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); + ; + return !near.storageWrite(storageKey, new Uint8Array()); } /** * Extends the current collection with the passed in array of elements. diff --git a/lib/collections/unordered-map.d.ts b/lib/collections/unordered-map.d.ts index 66c0a4ae5..63c8c7da0 100644 --- a/lib/collections/unordered-map.d.ts +++ b/lib/collections/unordered-map.d.ts @@ -1,19 +1,18 @@ -import { Bytes } from "../utils"; import { Vector } from "./vector"; import { LookupMap } from "./lookup-map"; import { GetOptions } from "../types/collections"; -declare type ValueAndIndex = [value: string, index: number]; +declare type ValueAndIndex = [value: Uint8Array, index: number]; /** * An unordered map that stores data in NEAR storage. */ export declare class UnorderedMap { - readonly prefix: Bytes; - readonly keys: Vector; + readonly prefix: Uint8Array; + readonly keys: Vector; readonly values: LookupMap; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(prefix: Bytes); + constructor(prefix: Uint8Array); /** * The number of elements stored in the collection. */ @@ -28,7 +27,7 @@ export declare class UnorderedMap { * @param key - The key at which to look for the data. * @param options - Options for retrieving the data. */ - get(key: Bytes, options?: Omit, "serializer">): DataType | null; + get(key: Uint8Array, options?: Omit, "serializer">): DataType | null; /** * Store a new value at the provided key. * @@ -36,14 +35,14 @@ export declare class UnorderedMap { * @param value - The value to store in the collection. * @param options - Options for retrieving and storing the data. */ - set(key: Bytes, value: DataType, options?: GetOptions): DataType | null; + set(key: Uint8Array, value: DataType, options?: GetOptions): DataType | null; /** * Removes and retrieves the element with the provided key. * * @param key - The key at which to remove data. * @param options - Options for retrieving the data. */ - remove(key: Bytes, options?: Omit, "serializer">): DataType | null; + remove(key: Uint8Array, options?: Omit, "serializer">): DataType | null; /** * Remove all of the elements stored within the collection. */ @@ -60,19 +59,19 @@ export declare class UnorderedMap { * * @param options - Options for retrieving and storing the data. */ - toArray(options?: GetOptions): [Bytes, DataType][]; + toArray(options?: GetOptions): [Uint8Array, DataType][]; /** * Extends the current collection with the passed in array of key-value pairs. * * @param keyValuePairs - The key-value pairs to extend the collection with. */ - extend(keyValuePairs: [Bytes, DataType][]): void; + extend(keyValuePairs: [Uint8Array, DataType][]): void; /** * Serialize the collection. * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string; + serialize(options?: Pick, "serializer">): Uint8Array; /** * Converts the deserialized data from storage to a JavaScript instance of the collection. * @@ -93,7 +92,7 @@ declare class UnorderedMapIterator { */ constructor(unorderedMap: UnorderedMap, options?: GetOptions); next(): { - value: [Bytes | null, DataType | null]; + value: [Uint8Array | null, DataType | null]; done: boolean; }; } diff --git a/lib/collections/unordered-map.js b/lib/collections/unordered-map.js index 961d1c29c..99c3d3adb 100644 --- a/lib/collections/unordered-map.js +++ b/lib/collections/unordered-map.js @@ -1,4 +1,4 @@ -import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, serializeValueWithOptions, } from "../utils"; +import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, latin1ToU8Array, serializeValueWithOptions, u8ArrayConcat, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; /** @@ -10,8 +10,8 @@ export class UnorderedMap { */ constructor(prefix) { this.prefix = prefix; - this.keys = new Vector(`${prefix}u`); // intentional different prefix with old UnorderedMap - this.values = new LookupMap(`${prefix}m`); + this.keys = new Vector(u8ArrayConcat(prefix, latin1ToU8Array('u'))); // intentional different prefix with old UnorderedMap + this.values = new LookupMap(u8ArrayConcat(prefix, latin1ToU8Array('m'))); } /** * The number of elements stored in the collection. @@ -144,10 +144,10 @@ export class UnorderedMap { static reconstruct(data) { const map = new UnorderedMap(data.prefix); // reconstruct keys Vector - map.keys = new Vector(`${data.prefix}u`); + map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array('u'))); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap(`${data.prefix}m`); + map.values = new LookupMap(u8ArrayConcat(data.prefix, latin1ToU8Array('m'))); return map; } } diff --git a/lib/collections/unordered-set.d.ts b/lib/collections/unordered-set.d.ts index fe4087e83..7f7f9aa88 100644 --- a/lib/collections/unordered-set.d.ts +++ b/lib/collections/unordered-set.d.ts @@ -1,17 +1,16 @@ -import { Bytes } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { GetOptions } from "../types/collections"; /** * An unordered set that stores data in NEAR storage. */ export declare class UnorderedSet { - readonly prefix: Bytes; - readonly elementIndexPrefix: Bytes; + readonly prefix: Uint8Array; + readonly elementIndexPrefix: Uint8Array; readonly elements: Vector; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(prefix: Bytes); + constructor(prefix: Uint8Array); /** * The number of elements stored in the collection. */ @@ -70,7 +69,7 @@ export declare class UnorderedSet { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string; + serialize(options?: Pick, "serializer">): Uint8Array; /** * Converts the deserialized data from storage to a JavaScript instance of the collection. * diff --git a/lib/collections/unordered-set.js b/lib/collections/unordered-set.js index e9ccdedbd..32ee66153 100644 --- a/lib/collections/unordered-set.js +++ b/lib/collections/unordered-set.js @@ -1,14 +1,13 @@ import * as near from "../api"; -import { u8ArrayToBytes, bytesToU8Array, assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, } from "../utils"; +import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, u8ArrayConcat, latin1ToU8Array, } from "../utils"; import { Vector, VectorIterator } from "./vector"; function serializeIndex(index) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return u8ArrayToBytes(array); + return array; } function deserializeIndex(rawIndex) { - const array = bytesToU8Array(rawIndex); - const [data] = new Uint32Array(array.buffer); + const [data] = new Uint32Array(rawIndex.buffer); return data; } /** @@ -20,8 +19,8 @@ export class UnorderedSet { */ constructor(prefix) { this.prefix = prefix; - this.elementIndexPrefix = `${prefix}i`; - this.elements = new Vector(`${prefix}e`); + this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array('i')); + this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array('e'))); } /** * The number of elements stored in the collection. @@ -42,7 +41,7 @@ export class UnorderedSet { * @param options - Options for storing data. */ contains(element, options) { - const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); return near.storageHasKey(indexLookup); } /** @@ -53,7 +52,7 @@ export class UnorderedSet { * @param options - Options for storing the data. */ set(element, options) { - const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); if (near.storageRead(indexLookup)) { return false; } @@ -70,7 +69,7 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element, options) { - const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); const indexRaw = near.storageRead(indexLookup); if (!indexRaw) { return false; @@ -91,8 +90,7 @@ export class UnorderedSet { // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = this.elementIndexPrefix + - serializeValueWithOptions(lastElement, options); + const lastLookupElement = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(lastElement, options)); near.storageWrite(lastLookupElement, indexRaw); } const index = deserializeIndex(indexRaw); @@ -104,7 +102,7 @@ export class UnorderedSet { */ clear(options) { for (const element of this.elements) { - const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); near.storageRemove(indexLookup); } this.elements.clear(); @@ -161,7 +159,7 @@ export class UnorderedSet { static reconstruct(data) { const set = new UnorderedSet(data.prefix); // reconstruct Vector - const elementsPrefix = data.prefix + "e"; + const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array('e')); set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; return set; diff --git a/lib/collections/vector.d.ts b/lib/collections/vector.d.ts index cce52610f..a867f4951 100644 --- a/lib/collections/vector.d.ts +++ b/lib/collections/vector.d.ts @@ -1,17 +1,16 @@ -import { Bytes } from "../utils"; import { GetOptions } from "../types/collections"; /** * An iterable implementation of vector that stores its content on the trie. * Uses the following map: index -> element */ export declare class Vector { - readonly prefix: Bytes; + readonly prefix: Uint8Array; length: number; /** * @param prefix - The byte prefix to use when storing elements inside this collection. * @param length - The initial length of the collection. By default 0. */ - constructor(prefix: Bytes, length?: number); + constructor(prefix: Uint8Array, length?: number); /** * Checks whether the collection is empty. */ @@ -81,7 +80,7 @@ export declare class Vector { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string; + serialize(options?: Pick, "serializer">): Uint8Array; /** * Converts the deserialized data from storage to a JavaScript instance of the collection. * diff --git a/lib/collections/vector.js b/lib/collections/vector.js index b7b730b71..13acc1b06 100644 --- a/lib/collections/vector.js +++ b/lib/collections/vector.js @@ -1,10 +1,9 @@ import * as near from "../api"; -import { assert, getValueWithOptions, u8ArrayToBytes, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, } from "../utils"; +import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, u8ArrayConcat, } from "../utils"; function indexToKey(prefix, index) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - const key = u8ArrayToBytes(array); - return prefix + key; + return u8ArrayConcat(prefix, array); } /** * An iterable implementation of vector that stores its content on the trie. diff --git a/src/collections/lookup-map.ts b/src/collections/lookup-map.ts index 6f38bc5d9..4fe5aa567 100644 --- a/src/collections/lookup-map.ts +++ b/src/collections/lookup-map.ts @@ -1,9 +1,9 @@ import * as near from "../api"; import { GetOptions } from "../types/collections"; import { - Bytes, getValueWithOptions, serializeValueWithOptions, + u8ArrayConcat, } from "../utils"; /** @@ -13,15 +13,15 @@ export class LookupMap { /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly keyPrefix: Bytes) {} + constructor(readonly keyPrefix: Uint8Array) {} /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. */ - containsKey(key: Bytes): boolean { - const storageKey = this.keyPrefix + key; + containsKey(key: Uint8Array): boolean { + const storageKey = u8ArrayConcat(this.keyPrefix, key); return near.storageHasKey(storageKey); } @@ -32,10 +32,10 @@ export class LookupMap { * @param options - Options for retrieving the data. */ get( - key: Bytes, + key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); const value = near.storageRead(storageKey); return getValueWithOptions(value, options); @@ -48,10 +48,10 @@ export class LookupMap { * @param options - Options for retrieving the data. */ remove( - key: Bytes, + key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; @@ -70,11 +70,11 @@ export class LookupMap { * @param options - Options for retrieving and storing the data. */ set( - key: Bytes, + key: Uint8Array, newValue: DataType, options?: GetOptions ): DataType | null { - const storageKey = this.keyPrefix + key; + const storageKey = u8ArrayConcat(this.keyPrefix, key); const storageValue = serializeValueWithOptions(newValue, options); if (!near.storageWrite(storageKey, storageValue)) { @@ -93,7 +93,7 @@ export class LookupMap { * @param options - Options for storing the data. */ extend( - keyValuePairs: [Bytes, DataType][], + keyValuePairs: [Uint8Array, DataType][], options?: GetOptions ): void { for (const [key, value] of keyValuePairs) { @@ -106,7 +106,7 @@ export class LookupMap { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string { + serialize(options?: Pick, "serializer">): Uint8Array { return serializeValueWithOptions(this, options); } diff --git a/src/collections/lookup-set.ts b/src/collections/lookup-set.ts index 5014a0b6d..bad4d075b 100644 --- a/src/collections/lookup-set.ts +++ b/src/collections/lookup-set.ts @@ -1,6 +1,6 @@ import * as near from "../api"; import { GetOptions } from "../types/collections"; -import { Bytes, serializeValueWithOptions } from "../utils"; +import { serializeValueWithOptions, u8ArrayConcat } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. @@ -9,7 +9,7 @@ export class LookupSet { /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly keyPrefix: Bytes) {} + constructor(readonly keyPrefix: Uint8Array) {} /** * Checks whether the collection contains the value. @@ -18,10 +18,13 @@ export class LookupSet { * @param options - Options for storing data. */ contains( - key: DataType, + key: Uint8Array, options?: Pick, "serializer"> ): boolean { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + const storageKey = u8ArrayConcat( + this.keyPrefix, + serializeValueWithOptions(key, options) + ); return near.storageHasKey(storageKey); } @@ -35,7 +38,10 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + const storageKey = u8ArrayConcat( + this.keyPrefix, + serializeValueWithOptions(key, options) + ); return near.storageRemove(storageKey); } @@ -50,8 +56,11 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return !near.storageWrite(storageKey, ""); + const storageKey = u8ArrayConcat( + this.keyPrefix, + serializeValueWithOptions(key, options) + ); + return !near.storageWrite(storageKey, new Uint8Array()); } /** @@ -72,7 +81,7 @@ export class LookupSet { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string { + serialize(options?: Pick, "serializer">): Uint8Array { return serializeValueWithOptions(this, options); } diff --git a/src/collections/unordered-map.ts b/src/collections/unordered-map.ts index 61d601611..aecfdaf71 100644 --- a/src/collections/unordered-map.ts +++ b/src/collections/unordered-map.ts @@ -1,30 +1,35 @@ import { assert, - Bytes, ERR_INCONSISTENT_STATE, getValueWithOptions, + latin1ToU8Array, Mutable, serializeValueWithOptions, + u8ArrayConcat, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; import { GetOptions } from "../types/collections"; -type ValueAndIndex = [value: string, index: number]; +type ValueAndIndex = [value: Uint8Array, index: number]; /** * An unordered map that stores data in NEAR storage. */ export class UnorderedMap { - readonly keys: Vector; + readonly keys: Vector; readonly values: LookupMap; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly prefix: Bytes) { - this.keys = new Vector(`${prefix}u`); // intentional different prefix with old UnorderedMap - this.values = new LookupMap(`${prefix}m`); + constructor(readonly prefix: Uint8Array) { + this.keys = new Vector( + u8ArrayConcat(prefix, latin1ToU8Array("u")) + ); // intentional different prefix with old UnorderedMap + this.values = new LookupMap( + u8ArrayConcat(prefix, latin1ToU8Array("m")) + ); } /** @@ -48,7 +53,7 @@ export class UnorderedMap { * @param options - Options for retrieving the data. */ get( - key: Bytes, + key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { const valueAndIndex = this.values.get(key); @@ -70,7 +75,7 @@ export class UnorderedMap { * @param options - Options for retrieving and storing the data. */ set( - key: Bytes, + key: Uint8Array, value: DataType, options?: GetOptions ): DataType | null { @@ -99,7 +104,7 @@ export class UnorderedMap { * @param options - Options for retrieving the data. */ remove( - key: Bytes, + key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { const oldValueAndIndex = this.values.remove(key); @@ -160,7 +165,7 @@ export class UnorderedMap { * * @param options - Options for retrieving and storing the data. */ - toArray(options?: GetOptions): [Bytes, DataType][] { + toArray(options?: GetOptions): [Uint8Array, DataType][] { const array = []; const iterator = options ? this.createIteratorWithOptions(options) : this; @@ -177,7 +182,7 @@ export class UnorderedMap { * * @param keyValuePairs - The key-value pairs to extend the collection with. */ - extend(keyValuePairs: [Bytes, DataType][]) { + extend(keyValuePairs: [Uint8Array, DataType][]) { for (const [key, value] of keyValuePairs) { this.set(key, value); } @@ -188,7 +193,7 @@ export class UnorderedMap { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string { + serialize(options?: Pick, "serializer">): Uint8Array { return serializeValueWithOptions(this, options); } @@ -205,10 +210,12 @@ export class UnorderedMap { const map = new UnorderedMap(data.prefix) as MutableUnorderedMap; // reconstruct keys Vector - map.keys = new Vector(`${data.prefix}u`); + map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array("u"))); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap(`${data.prefix}m`); + map.values = new LookupMap( + u8ArrayConcat(data.prefix, latin1ToU8Array("m")) + ); return map as UnorderedMap; } @@ -218,7 +225,7 @@ export class UnorderedMap { * An iterator for the UnorderedMap collection. */ class UnorderedMapIterator { - private keys: VectorIterator; + private keys: VectorIterator; private map: LookupMap; /** @@ -233,7 +240,7 @@ class UnorderedMapIterator { this.map = unorderedMap.values; } - next(): { value: [Bytes | null, DataType | null]; done: boolean } { + next(): { value: [Uint8Array | null, DataType | null]; done: boolean } { const key = this.keys.next(); if (key.done) { diff --git a/src/collections/unordered-set.ts b/src/collections/unordered-set.ts index 4516f0719..88f71e4c5 100644 --- a/src/collections/unordered-set.ts +++ b/src/collections/unordered-set.ts @@ -1,11 +1,10 @@ import * as near from "../api"; import { - u8ArrayToBytes, - bytesToU8Array, - Bytes, assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, + u8ArrayConcat, + latin1ToU8Array, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { Mutable } from "../utils"; @@ -15,12 +14,11 @@ function serializeIndex(index: number) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return u8ArrayToBytes(array); + return array; } -function deserializeIndex(rawIndex: Bytes): number { - const array = bytesToU8Array(rawIndex); - const [data] = new Uint32Array(array.buffer); +function deserializeIndex(rawIndex: Uint8Array): number { + const [data] = new Uint32Array(rawIndex.buffer); return data; } @@ -29,15 +27,15 @@ function deserializeIndex(rawIndex: Bytes): number { * An unordered set that stores data in NEAR storage. */ export class UnorderedSet { - readonly elementIndexPrefix: Bytes; + readonly elementIndexPrefix: Uint8Array; readonly elements: Vector; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly prefix: Bytes) { - this.elementIndexPrefix = `${prefix}i`; - this.elements = new Vector(`${prefix}e`); + constructor(readonly prefix: Uint8Array) { + this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array("i")); + this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("e"))); } /** @@ -64,8 +62,10 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = - this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat( + this.elementIndexPrefix, + serializeValueWithOptions(element, options) + ); return near.storageHasKey(indexLookup); } @@ -80,9 +80,10 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = - this.elementIndexPrefix + serializeValueWithOptions(element, options); - + const indexLookup = u8ArrayConcat( + this.elementIndexPrefix, + serializeValueWithOptions(element, options) + ); if (near.storageRead(indexLookup)) { return false; } @@ -102,8 +103,11 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element: DataType, options?: GetOptions): boolean { - const indexLookup = - this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat( + this.elementIndexPrefix, + serializeValueWithOptions(element, options) + ); + const indexRaw = near.storageRead(indexLookup); if (!indexRaw) { @@ -132,9 +136,11 @@ export class UnorderedSet { // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = - this.elementIndexPrefix + - serializeValueWithOptions(lastElement, options); + const lastLookupElement = u8ArrayConcat( + this.elementIndexPrefix, + serializeValueWithOptions(lastElement, options) + ); + near.storageWrite(lastLookupElement, indexRaw); } @@ -149,8 +155,10 @@ export class UnorderedSet { */ clear(options?: Pick, "serializer">): void { for (const element of this.elements) { - const indexLookup = - this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexLookup = u8ArrayConcat( + this.elementIndexPrefix, + serializeValueWithOptions(element, options) + ); near.storageRemove(indexLookup); } @@ -207,7 +215,7 @@ export class UnorderedSet { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string { + serialize(options?: Pick, "serializer">): Uint8Array { return serializeValueWithOptions(this, options); } @@ -223,7 +231,8 @@ export class UnorderedSet { type MutableUnorderedSet = Mutable>; const set = new UnorderedSet(data.prefix) as MutableUnorderedSet; // reconstruct Vector - const elementsPrefix = data.prefix + "e"; + const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array("e")); + set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; diff --git a/src/collections/vector.ts b/src/collections/vector.ts index 3765763de..df19b0ec7 100644 --- a/src/collections/vector.ts +++ b/src/collections/vector.ts @@ -1,21 +1,19 @@ import * as near from "../api"; import { assert, - Bytes, getValueWithOptions, - u8ArrayToBytes, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, + u8ArrayConcat, } from "../utils"; import { GetOptions } from "../types/collections"; -function indexToKey(prefix: Bytes, index: number): Bytes { +function indexToKey(prefix: Uint8Array, index: number): Uint8Array { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - const key = u8ArrayToBytes(array); - return prefix + key; + return u8ArrayConcat(prefix, array); } /** @@ -27,7 +25,7 @@ export class Vector { * @param prefix - The byte prefix to use when storing elements inside this collection. * @param length - The initial length of the collection. By default 0. */ - constructor(readonly prefix: Bytes, public length = 0) {} + constructor(readonly prefix: Uint8Array, public length = 0) {} /** * Checks whether the collection is empty. @@ -208,7 +206,7 @@ export class Vector { * * @param options - Options for storing the data. */ - serialize(options?: Pick, "serializer">): string { + serialize(options?: Pick, "serializer">): Uint8Array { return serializeValueWithOptions(this, options); } diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index 3803ac7b5..9bb01b3a2 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -1,5 +1,10 @@ import * as near from "./api"; -import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1 } from "./utils"; +import { + deserialize, + latin1ToU8Array, + serialize, + u8ArrayToLatin1, +} from "./utils"; type EmptyParameterObject = Record; type AnyObject = Record; @@ -171,7 +176,10 @@ export function NearBindgen({ } static _saveToStorage(objectToSave: unknown): void { - near.storageWrite(latin1ToU8Array("STATE"), this._serialize(objectToSave)); + near.storageWrite( + latin1ToU8Array("STATE"), + this._serialize(objectToSave) + ); } static _getArgs(): unknown { @@ -180,9 +188,11 @@ export function NearBindgen({ static _serialize(value: unknown, forReturn = false): Uint8Array { if (forReturn) { - return latin1ToU8Array(JSON.stringify(value, (_, value) => - typeof value === "bigint" ? `${value}` : value - )); + return latin1ToU8Array( + JSON.stringify(value, (_, value) => + typeof value === "bigint" ? `${value}` : value + ) + ); } return serializer(value); diff --git a/src/utils.ts b/src/utils.ts index 3571022ec..fbe1b00c2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,7 +37,7 @@ const ACCOUNT_ID_REGEX = */ export function u8ArrayToLatin1(array: Uint8Array): string { let ret = ""; - for (let e of array) { + for (const e of array) { ret += String.fromCharCode(e); } return ret; @@ -49,9 +49,9 @@ export function u8ArrayToLatin1(array: Uint8Array): string { * @returns result Uint8Array */ export function latin1ToU8Array(latin1: string): Uint8Array { - let ret = new Uint8Array(latin1.length); + const ret = new Uint8Array(latin1.length); for (let i = 0; i < latin1.length; i++) { - let code = latin1.charCodeAt(i); + const code = latin1.charCodeAt(i); if (code > 255) { throw new Error( `string at index ${i}: ${latin1[i]} is not a valid latin1 char` @@ -61,18 +61,21 @@ export function latin1ToU8Array(latin1: string): Uint8Array { } return ret; } - + /** * Concat two Uint8Array - * @param array1 - * @param array2 + * @param array1 + * @param array2 * @returns the concatenation of two array */ -export function u8ArrayConcat(array1: Uint8Array, array2: Uint8Array): Uint8Array { - let mergedArray = new Uint8Array(array1.length + array2.length); +export function u8ArrayConcat( + array1: Uint8Array, + array2: Uint8Array +): Uint8Array { + const mergedArray = new Uint8Array(array1.length + array2.length); mergedArray.set(array1); mergedArray.set(array2, array1.length); - return mergedArray + return mergedArray; } /** @@ -121,27 +124,29 @@ export function serializeValueWithOptions( } export function serialize(valueToSerialize: unknown): Uint8Array { - return latin1ToU8Array(JSON.stringify(valueToSerialize, function (key, value) { - if (typeof value === "bigint") { - return { - value: value.toString(), - [TYPE_KEY]: TypeBrand.BIGINT, - }; - } + return latin1ToU8Array( + JSON.stringify(valueToSerialize, function (key, value) { + if (typeof value === "bigint") { + return { + value: value.toString(), + [TYPE_KEY]: TypeBrand.BIGINT, + }; + } - if ( - typeof this[key] === "object" && - this[key] !== null && - this[key] instanceof Date - ) { - return { - value: this[key].toISOString(), - [TYPE_KEY]: TypeBrand.DATE, - }; - } + if ( + typeof this[key] === "object" && + this[key] !== null && + this[key] instanceof Date + ) { + return { + value: this[key].toISOString(), + [TYPE_KEY]: TypeBrand.DATE, + }; + } - return value; - })); + return value; + }) + ); } export function deserialize(valueToDeserialize: Uint8Array): unknown { From b933287c45b28922382bd684ab86c48f4cddb5b0 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 30 Nov 2022 11:08:03 +0800 Subject: [PATCH 08/24] commit build --- lib/collections/lookup-set.js | 2 -- lib/collections/unordered-map.js | 8 ++++---- lib/collections/unordered-set.js | 6 +++--- lib/near-bindgen.js | 2 +- lib/utils.js | 8 ++++---- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/collections/lookup-set.js b/lib/collections/lookup-set.js index d257abb5a..0b5a3eca6 100644 --- a/lib/collections/lookup-set.js +++ b/lib/collections/lookup-set.js @@ -28,7 +28,6 @@ export class LookupSet { */ remove(key, options) { const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); - ; return near.storageRemove(storageKey); } /** @@ -40,7 +39,6 @@ export class LookupSet { */ set(key, options) { const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); - ; return !near.storageWrite(storageKey, new Uint8Array()); } /** diff --git a/lib/collections/unordered-map.js b/lib/collections/unordered-map.js index 99c3d3adb..09ea40d01 100644 --- a/lib/collections/unordered-map.js +++ b/lib/collections/unordered-map.js @@ -10,8 +10,8 @@ export class UnorderedMap { */ constructor(prefix) { this.prefix = prefix; - this.keys = new Vector(u8ArrayConcat(prefix, latin1ToU8Array('u'))); // intentional different prefix with old UnorderedMap - this.values = new LookupMap(u8ArrayConcat(prefix, latin1ToU8Array('m'))); + this.keys = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("u"))); // intentional different prefix with old UnorderedMap + this.values = new LookupMap(u8ArrayConcat(prefix, latin1ToU8Array("m"))); } /** * The number of elements stored in the collection. @@ -144,10 +144,10 @@ export class UnorderedMap { static reconstruct(data) { const map = new UnorderedMap(data.prefix); // reconstruct keys Vector - map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array('u'))); + map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array("u"))); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap(u8ArrayConcat(data.prefix, latin1ToU8Array('m'))); + map.values = new LookupMap(u8ArrayConcat(data.prefix, latin1ToU8Array("m"))); return map; } } diff --git a/lib/collections/unordered-set.js b/lib/collections/unordered-set.js index 32ee66153..3b0c14c98 100644 --- a/lib/collections/unordered-set.js +++ b/lib/collections/unordered-set.js @@ -19,8 +19,8 @@ export class UnorderedSet { */ constructor(prefix) { this.prefix = prefix; - this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array('i')); - this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array('e'))); + this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array("i")); + this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("e"))); } /** * The number of elements stored in the collection. @@ -159,7 +159,7 @@ export class UnorderedSet { static reconstruct(data) { const set = new UnorderedSet(data.prefix); // reconstruct Vector - const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array('e')); + const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array("e")); set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; return set; diff --git a/lib/near-bindgen.js b/lib/near-bindgen.js index 15fdbb6c1..71b995a46 100644 --- a/lib/near-bindgen.js +++ b/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1 } from "./utils"; +import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1, } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * diff --git a/lib/utils.js b/lib/utils.js index acd958797..46e8b6462 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -19,7 +19,7 @@ const ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/ */ export function u8ArrayToLatin1(array) { let ret = ""; - for (let e of array) { + for (const e of array) { ret += String.fromCharCode(e); } return ret; @@ -30,9 +30,9 @@ export function u8ArrayToLatin1(array) { * @returns result Uint8Array */ export function latin1ToU8Array(latin1) { - let ret = new Uint8Array(latin1.length); + const ret = new Uint8Array(latin1.length); for (let i = 0; i < latin1.length; i++) { - let code = latin1.charCodeAt(i); + const code = latin1.charCodeAt(i); if (code > 255) { throw new Error(`string at index ${i}: ${latin1[i]} is not a valid latin1 char`); } @@ -47,7 +47,7 @@ export function latin1ToU8Array(latin1) { * @returns the concatenation of two array */ export function u8ArrayConcat(array1, array2) { - let mergedArray = new Uint8Array(array1.length + array2.length); + const mergedArray = new Uint8Array(array1.length + array2.length); mergedArray.set(array1); mergedArray.set(array2, array1.length); return mergedArray; From e927de72da42275700b5e5a94ef89fe6c262c222 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 30 Nov 2022 18:19:38 +0800 Subject: [PATCH 09/24] fix build and some tests --- builder/builder.c | 4 ++-- lib/utils.d.ts | 4 ++++ lib/utils.js | 6 +++++ src/utils.ts | 7 ++++++ tests/__tests__/test_log_panic_api.ava.js | 13 ++--------- tests/__tests__/test_promise_api.ava.js | 2 +- tests/src/context_api.js | 28 ++++++++++++----------- tests/src/log_panic_api.js | 7 ------ tests/src/math_api.js | 25 ++++++++------------ tests/src/promise_api.js | 6 ++--- tests/src/storage_api.js | 14 +++++++++--- 11 files changed, 61 insertions(+), 55 deletions(-) diff --git a/builder/builder.c b/builder/builder.c index c25984dba..91a997d04 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -1,6 +1,6 @@ #include -#include "../node_modules/near-sdk-js/cli/deps/quickjs/quickjs-libc-min.h" -#include "../node_modules/near-sdk-js/cli/deps/quickjs/libbf.h" +#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/quickjs-libc-min.h" +#include "../node_modules/near-sdk-js/lib/cli/deps/quickjs/libbf.h" #include "code.h" static JSContext *JS_NewCustomContext(JSRuntime *rt) diff --git a/lib/utils.d.ts b/lib/utils.d.ts index 351ecf140..d0c76184e 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -28,6 +28,10 @@ export declare function u8ArrayToLatin1(array: Uint8Array): string; * @returns result Uint8Array */ export declare function latin1ToU8Array(latin1: string): Uint8Array; +/** + * Alias to latin1ToU8Array + */ +export declare function bytes(s: string): Uint8Array; /** * Concat two Uint8Array * @param array1 diff --git a/lib/utils.js b/lib/utils.js index 46e8b6462..86a655c2f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -40,6 +40,12 @@ export function latin1ToU8Array(latin1) { } return ret; } +/** + * Alias to latin1ToU8Array + */ +export function bytes(s) { + return latin1ToU8Array(s); +} /** * Concat two Uint8Array * @param array1 diff --git a/src/utils.ts b/src/utils.ts index fbe1b00c2..7c8632255 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -62,6 +62,13 @@ export function latin1ToU8Array(latin1: string): Uint8Array { return ret; } +/** + * Alias to latin1ToU8Array + */ +export function bytes(s: string): Uint8Array { + return latin1ToU8Array(s); +} + /** * Concat two Uint8Array * @param array1 diff --git a/tests/__tests__/test_log_panic_api.ava.js b/tests/__tests__/test_log_panic_api.ava.js index 70e9f9cb8..885c07245 100644 --- a/tests/__tests__/test_log_panic_api.ava.js +++ b/tests/__tests__/test_log_panic_api.ava.js @@ -33,22 +33,13 @@ test("Log expected types work", async (t) => { "abc", "水", "333", - "\x00\x01\xff", - "\xe6\xb0\xb4", + '{"0":0,"1":1,"2":255}', + '{"0":230,"1":176,"2":180}', "水", "水", ]); }); -test("Log unexpected types not logging", async (t) => { - const { ali, testContract } = t.context.accounts; - - let r = await ali.callRaw(testContract, "log_unexpected_input_tests", ""); - // logUtf8 and logUtf16 only works with bytes, trying to log it with string is unexpected and behavior is undefined - // in this specific case, it logs nothing - t.deepEqual(r.result.receipts_outcome[0].outcome.logs, ["", ""]); -}); - test("Log invalid utf-8 sequence panic", async (t) => { const { ali, testContract } = t.context.accounts; diff --git a/tests/__tests__/test_promise_api.ava.js b/tests/__tests__/test_promise_api.ava.js index 1cfb4202b..ac217c7f1 100644 --- a/tests/__tests__/test_promise_api.ava.js +++ b/tests/__tests__/test_promise_api.ava.js @@ -92,7 +92,7 @@ test("promise then", async (t) => { currentAccountId: calleeContract.accountId, signerAccountId: ali.accountId, predecessorAccountId: callerContract.accountId, - input: "abc", + input: { 0: 97, 1: 98, 2: 99 }, } ); diff --git a/tests/src/context_api.js b/tests/src/context_api.js index 9560fcdd9..3f72dfd6c 100644 --- a/tests/src/context_api.js +++ b/tests/src/context_api.js @@ -1,15 +1,15 @@ -import { near } from "near-sdk-js"; +import { near, bytes } from "near-sdk-js"; export function get_current_account_id() { - near.valueReturn(near.currentAccountId()); + near.valueReturn(bytes(near.currentAccountId())); } export function get_signer_account_id() { - near.valueReturn(near.signerAccountId()); + near.valueReturn(bytes(near.signerAccountId())); } export function get_predecessor_account_id() { - near.valueReturn(near.predecessorAccountId()); + near.valueReturn(bytes(near.predecessorAccountId())); } export function get_signer_account_pk() { @@ -21,31 +21,31 @@ export function get_input() { } export function get_storage_usage() { - near.valueReturn(near.storageUsage()); + near.valueReturn(bytes(near.storageUsage().toString())); } export function get_block_height() { - near.valueReturn(near.blockHeight()); + near.valueReturn(bytes(near.blockHeight().toString())); } export function get_block_timestamp() { - near.valueReturn(near.blockTimestamp()); + near.valueReturn(bytes(near.blockTimestamp().toString())); } export function get_epoch_height() { - near.valueReturn(near.epochHeight()); + near.valueReturn(bytes(near.epochHeight().toString())); } export function get_attached_deposit() { - near.valueReturn(JSON.stringify(near.attachedDeposit().toString())); + near.valueReturn(bytes(JSON.stringify(near.attachedDeposit().toString()))); } export function get_prepaid_gas() { - near.valueReturn(near.prepaidGas()); + near.valueReturn(bytes(near.prepaidGas().toString())); } export function get_used_gas() { - near.valueReturn(near.usedGas()); + near.valueReturn(bytes(near.usedGas().toString())); } export function get_random_seed() { @@ -53,9 +53,11 @@ export function get_random_seed() { } export function get_validator_stake() { - near.valueReturn(near.validatorStake(near.signerAccountId())); + near.valueReturn( + bytes(near.validatorStake(near.signerAccountId()).toString()) + ); } export function get_total_stake() { - near.valueReturn(near.validatorTotalStake()); + near.valueReturn(bytes(near.validatorTotalStake().toString())); } diff --git a/tests/src/log_panic_api.js b/tests/src/log_panic_api.js index 868ccd483..1d386ca45 100644 --- a/tests/src/log_panic_api.js +++ b/tests/src/log_panic_api.js @@ -18,13 +18,6 @@ export function log_expected_input_tests() { near.logUtf16(bytes("\x34\x6c")); } -export function log_unexpected_input_tests() { - // log non-bytes with logUtf8 - near.logUtf8("水"); - // log non-bytes with logUtf16 - near.logUtf16("水"); -} - export function log_invalid_utf8_sequence_test() { near.logUtf8(bytes("\x00\x01\xff")); } diff --git a/tests/src/math_api.js b/tests/src/math_api.js index 93d2d72d4..0f789130d 100644 --- a/tests/src/math_api.js +++ b/tests/src/math_api.js @@ -17,21 +17,16 @@ export function test_ripemd160() { } export function test_ecrecover() { - let hash = bytes( - new Uint8Array([ - 206, 6, 119, 187, 48, 186, 168, 207, 6, 124, 136, 219, 152, 17, 244, 51, - 61, 19, 27, 248, 188, 241, 47, 231, 6, 93, 33, 29, 206, 151, 16, 8, - ]) - ); - let sign = bytes( - new Uint8Array([ - 144, 242, 123, 139, 72, 141, 176, 11, 0, 96, 103, 150, 210, 152, 127, 106, - 95, 89, 174, 98, 234, 5, 239, 254, 132, 254, 245, 184, 176, 229, 73, 152, - 74, 105, 17, 57, 173, 87, 163, 240, 185, 6, 99, 118, 115, 170, 47, 99, - 209, 245, 92, 177, 166, 145, 153, 212, 0, 158, 234, 35, 206, 173, 220, - 147, - ]) - ); + let hash = new Uint8Array([ + 206, 6, 119, 187, 48, 186, 168, 207, 6, 124, 136, 219, 152, 17, 244, 51, 61, + 19, 27, 248, 188, 241, 47, 231, 6, 93, 33, 29, 206, 151, 16, 8, + ]); + let sign = new Uint8Array([ + 144, 242, 123, 139, 72, 141, 176, 11, 0, 96, 103, 150, 210, 152, 127, 106, + 95, 89, 174, 98, 234, 5, 239, 254, 132, 254, 245, 184, 176, 229, 73, 152, + 74, 105, 17, 57, 173, 87, 163, 240, 185, 6, 99, 118, 115, 170, 47, 99, 209, + 245, 92, 177, 166, 145, 153, 212, 0, 158, 234, 35, 206, 173, 220, 147, + ]); let v = 1; let malleabilityFlag = 1; let ret = near.ecrecover(hash, sign, v, malleabilityFlag); diff --git a/tests/src/promise_api.js b/tests/src/promise_api.js index cb3b6a351..da42639f6 100644 --- a/tests/src/promise_api.js +++ b/tests/src/promise_api.js @@ -10,9 +10,9 @@ export function just_panic() { export function write_some_state() { // Attempt to write something in state. If this one is successfully executed and not revoked, these should be in state - near.storageWrite("aaa", "bbb"); - near.storageWrite("ccc", "ddd"); - near.storageWrite("eee", "fff"); + near.storageWrite(bytes("aaa"), bytes("bbb")); + near.storageWrite(bytes("ccc"), bytes("ddd")); + near.storageWrite(bytes("eee"), bytes("fff")); } function callingData() { diff --git a/tests/src/storage_api.js b/tests/src/storage_api.js index 238257e83..78fc86453 100644 --- a/tests/src/storage_api.js +++ b/tests/src/storage_api.js @@ -2,7 +2,11 @@ import { near, bytes } from "near-sdk-js"; export function test_storage_write() { near.valueReturn( - near.storageWrite(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")) + bytes( + near + .storageWrite(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")) + .toString() + ) ); } @@ -11,11 +15,15 @@ export function test_storage_read() { } export function test_storage_remove() { - near.valueReturn(near.storageRemove(bytes("\x00tesdsst\xff"))); + near.valueReturn( + bytes(near.storageRemove(bytes("\x00tesdsst\xff")).toString()) + ); } export function test_storage_has_key() { - near.valueReturn(near.storageHasKey(bytes("\x00tesdsst\xff"))); + near.valueReturn( + bytes(near.storageHasKey(bytes("\x00tesdsst\xff")).toString()) + ); } export function test_storage_get_evicted() { From c09a8db42d856524adc3fcbb0d36cef04b3d2ab0 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 1 Dec 2022 16:51:15 +0800 Subject: [PATCH 10/24] add text encoding decoding in c side, add TextEncoder and TextDecoder, fix promise api --- builder/builder.c | 55 + lib/api.d.ts | 10 + lib/api.js | 25 + lib/build-tools/include-bytes.js | 2 +- lib/index.d.ts | 1 + lib/index.js | 1 + lib/utils.d.ts | 5 +- lib/utils.js | 10 +- src/api.ts | 31 + src/build-tools/include-bytes.ts | 2 +- src/index.ts | 1 + src/utils.ts | 11 +- tests/__tests__/test_promise_api.ava.js | 6 +- tests/package.json | 3 + tests/src/promise_api.js | 6 +- tests/yarn.lock | 1293 +++++++++++++++++------ 16 files changed, 1142 insertions(+), 320 deletions(-) diff --git a/builder/builder.c b/builder/builder.c index 91a997d04..b1221682f 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -1006,6 +1006,56 @@ static JSValue near_validator_total_stake(JSContext *ctx, JSValueConst this_val, return u128_to_quickjs(ctx, stake_ptr); } +static JSValue near_utf8_string_to_uint8array(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + char *data; + size_t len; + JSValue arraybuffer; + + data = JS_ToCStringLen(ctx, &len, argv[0]); + + arraybuffer = JS_NewArrayBuffer(ctx, data, len, NULL, NULL, TRUE); + return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); +} + +static JSValue near_latin1_string_to_uint8array(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + char *data; + size_t len; + JSValue arraybuffer; + + data = JS_ToCStringLenRaw(ctx, &len, argv[0]); + + arraybuffer = JS_NewArrayBuffer(ctx, data, len, NULL, NULL, TRUE); + return JS_CallConstructor(ctx, JS_GetPropertyStr(ctx, JS_GetGlobalObject(ctx), "Uint8Array"), 1, (JSValueConst *)&arraybuffer); +} + +static JSValue near_uint8array_to_latin1_string(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array"); + } + + return JS_NewStringLenRaw(ctx, data_ptr, data_len); +} + +static JSValue near_uint8array_to_utf8_string(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ + uint8_t *data_ptr; + size_t data_len; + + data_ptr = JS_Uint8Array_to_C(ctx, argv[0], &data_len); + if (data_ptr == NULL) { + return JS_ThrowTypeError(ctx, "Expect Uint8Array"); + } + + return JS_NewStringLen(ctx, data_ptr, data_len); +} + #ifdef NIGHTLY static JSValue near_alt_bn128_g1_multiexp(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { @@ -1125,6 +1175,11 @@ static void js_add_near_host_functions(JSContext* ctx) { JS_SetPropertyStr(ctx, env, "alt_bn128_pairing_check", JS_NewCFunction(ctx, near_alt_bn128_pairing_check, "alt_bn128_pairing_check", 1)); #endif + JS_SetPropertyStr(ctx, env, "latin1_string_to_uint8array", JS_NewCFunction(ctx, near_latin1_string_to_uint8array, "latin1_string_to_uint8array", 1)); + JS_SetPropertyStr(ctx, env, "utf8_string_to_uint8array", JS_NewCFunction(ctx, near_utf8_string_to_uint8array, "utf8_string_to_uint8array", 1)); + JS_SetPropertyStr(ctx, env, "uint8array_to_latin1_string", JS_NewCFunction(ctx, near_uint8array_to_latin1_string, "uint8array_to_latin1_string", 1)); + JS_SetPropertyStr(ctx, env, "uint8array_to_utf8_string", JS_NewCFunction(ctx, near_uint8array_to_utf8_string, "uint8array_to_utf8_string", 1)); + JS_SetPropertyStr(ctx, global_obj, "env", env); } diff --git a/lib/api.d.ts b/lib/api.d.ts index d905af59d..7ebe7f11c 100644 --- a/lib/api.d.ts +++ b/lib/api.d.ts @@ -355,3 +355,13 @@ export declare function altBn128G1Sum(value: Uint8Array): Uint8Array; * @returns whether pairing check pass */ export declare function altBn128PairingCheck(value: Uint8Array): boolean; +export declare class TextEncoder { + constructor(); + encode(s: string): Uint8Array; +} +export declare class TextDecoder { + encoding: string; + constructor(encoding?: string); + decode(a: Uint8Array): string; +} +export declare function bytes(s: string): Uint8Array; diff --git a/lib/api.js b/lib/api.js index 4178e3a63..eb43ac8b8 100644 --- a/lib/api.js +++ b/lib/api.js @@ -503,3 +503,28 @@ export function altBn128G1Sum(value) { export function altBn128PairingCheck(value) { return env.alt_bn128_pairing_check(value) === 1n; } +export class TextEncoder { + constructor() { } + encode(s) { + return env.utf8_string_to_uint8array(s); + } +} +export class TextDecoder { + constructor(encoding = 'utf-8') { + this.encoding = encoding; + } + decode(a) { + if (this.encoding == 'utf-8') { + return env.uint8array_to_utf8_string(a); + } + else if (this.encoding == 'latin1') { + return env.uint8array_to_latin1_string(a); + } + else { + throw new Error('unsupported encoding: ' + this.encoding); + } + } +} +export function bytes(s) { + return env.latin1_string_to_uint8array(s); +} diff --git a/lib/build-tools/include-bytes.js b/lib/build-tools/include-bytes.js index 48ef554bf..c7b04e31c 100644 --- a/lib/build-tools/include-bytes.js +++ b/lib/build-tools/include-bytes.js @@ -35,7 +35,7 @@ export default function () { const fileRelPath = firstArg.value; // Get literal string value const filePath = join(root, fileRelPath); const fileSrc = readFileSync(filePath, { encoding }).toString(); - path.replaceWith(t.stringLiteral(fileSrc)); + path.replaceWith(t.callExpression(t.memberExpression(t.identifier('env'), t.identifier('latin1_string_to_uint8array')), [t.stringLiteral(fileSrc)])); } }, }, diff --git a/lib/index.d.ts b/lib/index.d.ts index 434577a5e..e3495d782 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,4 +1,5 @@ export * as near from "./api"; +export { bytes } from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/lib/index.js b/lib/index.js index 434577a5e..e3495d782 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,5 @@ export * as near from "./api"; +export { bytes } from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/lib/utils.d.ts b/lib/utils.d.ts index d0c76184e..bf1bdcfbd 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -31,7 +31,10 @@ export declare function latin1ToU8Array(latin1: string): Uint8Array; /** * Alias to latin1ToU8Array */ -export declare function bytes(s: string): Uint8Array; +/** + * Alias to u8ArrayToLatin1 + */ +export declare function str(a: Uint8Array): string; /** * Concat two Uint8Array * @param array1 diff --git a/lib/utils.js b/lib/utils.js index 86a655c2f..7e0302248 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -43,8 +43,14 @@ export function latin1ToU8Array(latin1) { /** * Alias to latin1ToU8Array */ -export function bytes(s) { - return latin1ToU8Array(s); +// export function bytes(s: string): Uint8Array { +// return latin1ToU8Array(s); +// } +/** + * Alias to u8ArrayToLatin1 + */ +export function str(a) { + return u8ArrayToLatin1(a); } /** * Concat two Uint8Array diff --git a/src/api.ts b/src/api.ts index 05419c2c0..3dfabfe92 100644 --- a/src/api.ts +++ b/src/api.ts @@ -140,6 +140,11 @@ interface Env { promise_results_count(): bigint; promise_result(promiseIndex: bigint, register: Register): PromiseResult; promise_return(promiseIndex: bigint): void; + + uint8array_to_latin1_string(a: Uint8Array): string; + uint8array_to_utf8_string(a: Uint8Array): string; + latin1_string_to_uint8array(s: string): Uint8Array; + utf8_string_to_uint8array(s: string): Uint8Array; } declare const env: Env; @@ -834,3 +839,29 @@ export function altBn128G1Sum(value: Uint8Array): Uint8Array { export function altBn128PairingCheck(value: Uint8Array): boolean { return env.alt_bn128_pairing_check(value) === 1n; } + +export class TextEncoder { + constructor() {} + + encode(s: string): Uint8Array { + return env.utf8_string_to_uint8array(s) + } +} + +export class TextDecoder { + constructor(public encoding: string = 'utf-8') {} + + decode(a: Uint8Array): string { + if (this.encoding == 'utf-8') { + return env.uint8array_to_utf8_string(a) + } else if (this.encoding == 'latin1') { + return env.uint8array_to_latin1_string(a) + } else { + throw new Error('unsupported encoding: ' + this.encoding) + } + } +} + +export function bytes(s: string): Uint8Array { + return env.latin1_string_to_uint8array(s) +} diff --git a/src/build-tools/include-bytes.ts b/src/build-tools/include-bytes.ts index 5aabd83a5..b0f82b111 100644 --- a/src/build-tools/include-bytes.ts +++ b/src/build-tools/include-bytes.ts @@ -56,7 +56,7 @@ export default function (): { visitor: Visitor } { const filePath = join(root, fileRelPath); const fileSrc = readFileSync(filePath, { encoding }).toString(); - path.replaceWith(t.stringLiteral(fileSrc) as Node); + path.replaceWith(t.callExpression(t.memberExpression(t.identifier('env'), t.identifier('latin1_string_to_uint8array')), [t.stringLiteral(fileSrc)]) as Node); } }, }, diff --git a/src/index.ts b/src/index.ts index 434577a5e..47fa702b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export * as near from "./api"; +export {bytes} from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/src/utils.ts b/src/utils.ts index 7c8632255..2bb698b2e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -65,8 +65,15 @@ export function latin1ToU8Array(latin1: string): Uint8Array { /** * Alias to latin1ToU8Array */ -export function bytes(s: string): Uint8Array { - return latin1ToU8Array(s); +// export function bytes(s: string): Uint8Array { +// return latin1ToU8Array(s); +// } + +/** + * Alias to u8ArrayToLatin1 + */ +export function str(a: Uint8Array): string { + return u8ArrayToLatin1(a) } /** diff --git a/tests/__tests__/test_promise_api.ava.js b/tests/__tests__/test_promise_api.ava.js index ac217c7f1..69787e421 100644 --- a/tests/__tests__/test_promise_api.ava.js +++ b/tests/__tests__/test_promise_api.ava.js @@ -92,7 +92,7 @@ test("promise then", async (t) => { currentAccountId: calleeContract.accountId, signerAccountId: ali.accountId, predecessorAccountId: callerContract.accountId, - input: { 0: 97, 1: 98, 2: 99 }, + input: "abc", } ); @@ -232,8 +232,10 @@ test("promise batch deploy contract and call", async (t) => { caller2Contract, "test_promise_batch_deploy_call", "", - { gas: "200 Tgas" } + { gas: "300 Tgas" } ); + console.log(JSON.stringify(r, null, 2)) + let deployed = caller2Contract.getSubAccount("b"); t.deepEqual(JSON.parse(Buffer.from(r.result.status.SuccessValue, "base64")), { currentAccountId: deployed.accountId, diff --git a/tests/package.json b/tests/package.json index 179f794eb..ffb988c7b 100644 --- a/tests/package.json +++ b/tests/package.json @@ -56,6 +56,9 @@ }, "author": "Near Inc ", "license": "Apache-2.0", + "dependencies": { + "near-sdk-js": "file:../" + }, "devDependencies": { "ava": "^4.2.0", "near-workspaces": "3.2.1", diff --git a/tests/src/promise_api.js b/tests/src/promise_api.js index da42639f6..01632c4fb 100644 --- a/tests/src/promise_api.js +++ b/tests/src/promise_api.js @@ -1,4 +1,4 @@ -import { near, bytes } from "near-sdk-js"; +import { near, str, bytes } from "near-sdk-js"; function arrayN(n) { return [...Array(Number(n)).keys()]; @@ -20,7 +20,7 @@ function callingData() { currentAccountId: near.currentAccountId(), signerAccountId: near.signerAccountId(), predecessorAccountId: near.predecessorAccountId(), - input: near.input(), + input: str(near.input()), }; } @@ -38,7 +38,7 @@ export function cross_contract_callback() { JSON.stringify({ ...callingData(), promiseResults: arrayN(near.promiseResultsCount()).map((i) => - near.promiseResult(i) + str(near.promiseResult(i)) ), }) ) diff --git a/tests/yarn.lock b/tests/yarn.lock index b058ed57c..5c233f049 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -2,9 +2,329 @@ # yarn lockfile v1 +"@ampproject/remapping@^2.1.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" + integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== + dependencies: + "@jridgewell/gen-mapping" "^0.1.0" + "@jridgewell/trace-mapping" "^0.3.9" + +"@babel/code-frame@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" + integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== + dependencies: + "@babel/highlight" "^7.18.6" + +"@babel/compat-data@^7.20.0": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733" + integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g== + +"@babel/core@^7.17.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.5.tgz#45e2114dc6cd4ab167f81daf7820e8fa1250d113" + integrity sha512-UdOWmk4pNWTm/4DlPUl/Pt4Gz4rcEMb7CY0Y3eJl5Yz1vI8ZJGmHWaVE55LoxRjdpx0z259GE9U5STA9atUinQ== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.5" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-module-transforms" "^7.20.2" + "@babel/helpers" "^7.20.5" + "@babel/parser" "^7.20.5" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.5" + "@babel/types" "^7.20.5" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" + +"@babel/generator@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.5.tgz#cb25abee3178adf58d6814b68517c62bdbfdda95" + integrity sha512-jl7JY2Ykn9S0yj4DQP82sYvPU+T3g0HFcWTqDLqiuA9tGRNIj9VfbtXGAYTTkyNEnQk1jkMGOdYka8aG/lulCA== + dependencies: + "@babel/types" "^7.20.5" + "@jridgewell/gen-mapping" "^0.3.2" + jsesc "^2.5.1" + +"@babel/helper-annotate-as-pure@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" + integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-compilation-targets@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" + integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== + dependencies: + "@babel/compat-data" "^7.20.0" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.21.3" + semver "^6.3.0" + +"@babel/helper-create-class-features-plugin@^7.20.2", "@babel/helper-create-class-features-plugin@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.20.5.tgz#327154eedfb12e977baa4ecc72e5806720a85a06" + integrity sha512-3RCdA/EmEaikrhayahwToF0fpweU/8o2p8vhc1c/1kftHOdTKuC65kik/TLc+qfbS8JKw4qqJbne4ovICDhmww== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.19.0" + "@babel/helper-member-expression-to-functions" "^7.18.9" + "@babel/helper-optimise-call-expression" "^7.18.6" + "@babel/helper-replace-supers" "^7.19.1" + "@babel/helper-split-export-declaration" "^7.18.6" + +"@babel/helper-environment-visitor@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" + integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== + +"@babel/helper-function-name@^7.19.0": + version "7.19.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz#941574ed5390682e872e52d3f38ce9d1bef4648c" + integrity sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w== + dependencies: + "@babel/template" "^7.18.10" + "@babel/types" "^7.19.0" + +"@babel/helper-hoist-variables@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" + integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-member-expression-to-functions@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz#1531661e8375af843ad37ac692c132841e2fd815" + integrity sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg== + dependencies: + "@babel/types" "^7.18.9" + +"@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" + integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-module-transforms@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" + integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" + +"@babel/helper-optimise-call-expression@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" + integrity sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629" + integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ== + +"@babel/helper-replace-supers@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.19.1.tgz#e1592a9b4b368aa6bdb8784a711e0bcbf0612b78" + integrity sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-member-expression-to-functions" "^7.18.9" + "@babel/helper-optimise-call-expression" "^7.18.6" + "@babel/traverse" "^7.19.1" + "@babel/types" "^7.19.0" + +"@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== + dependencies: + "@babel/types" "^7.20.2" + +"@babel/helper-split-export-declaration@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" + integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== + +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" + integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== + +"@babel/helper-validator-option@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" + integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== + +"@babel/helpers@^7.20.5": + version "7.20.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.6.tgz#e64778046b70e04779dfbdf924e7ebb45992c763" + integrity sha512-Pf/OjgfgFRW5bApskEz5pvidpim7tEDPlFtKcNRXWmfHGn9IEI2W2flqRQXTFb7gIPTyK++N6rVHuwKut4XK6w== + dependencies: + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.5" + "@babel/types" "^7.20.5" + +"@babel/highlight@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" + integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== + dependencies: + "@babel/helper-validator-identifier" "^7.18.6" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@babel/parser@^7.18.10", "@babel/parser@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.5.tgz#7f3c7335fe417665d929f34ae5dceae4c04015e8" + integrity sha512-r27t/cy/m9uKLXQNWWebeCUHgnAZq0CpG1OwKRxzJMP1vpSU4bSIK2hq+/cp0bQxetkXx38n09rNu8jVkcK/zA== + +"@babel/plugin-proposal-decorators@^7.17.2": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.20.5.tgz#28ba1a0e5044664a512967a19407d7fc26925394" + integrity sha512-Lac7PpRJXcC3s9cKsBfl+uc+DYXU5FD06BrTFunQO6QIQT+DwyzDPURAowI3bcvD1dZF/ank1Z5rstUJn3Hn4Q== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.20.5" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-replace-supers" "^7.19.1" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/plugin-syntax-decorators" "^7.19.0" + +"@babel/plugin-syntax-decorators@^7.19.0": + version "7.19.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.19.0.tgz#5f13d1d8fce96951bea01a10424463c9a5b3a599" + integrity sha512-xaBZUEDntt4faL1yN8oIFlhfXeQAWJW7CLKYsHTUqriCUbj8xOra8bfxxKGi/UwExPFBuPdH4XfHc9rGQhrVkQ== + dependencies: + "@babel/helper-plugin-utils" "^7.19.0" + +"@babel/plugin-syntax-typescript@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7" + integrity sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.19.0" + +"@babel/plugin-transform-typescript@^7.18.6": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.20.2.tgz#91515527b376fc122ba83b13d70b01af8fe98f3f" + integrity sha512-jvS+ngBfrnTUBfOQq8NfGnSbF9BrqlR6hjJ2yVxMkmO5nL/cdifNbI30EfjRlN4g5wYWNnMPyj5Sa6R1pbLeag== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.20.2" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-typescript" "^7.20.0" + +"@babel/preset-typescript@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399" + integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ== + dependencies: + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-validator-option" "^7.18.6" + "@babel/plugin-transform-typescript" "^7.18.6" + +"@babel/template@^7.18.10": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" + integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/parser" "^7.18.10" + "@babel/types" "^7.18.10" + +"@babel/traverse@^7.19.1", "@babel/traverse@^7.20.1", "@babel/traverse@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.5.tgz#78eb244bea8270fdda1ef9af22a5d5e5b7e57133" + integrity sha512-WM5ZNN3JITQIq9tFZaw1ojLU3WgWdtkxnhM1AegMS+PvHjkM5IXjmYEGY7yukz5XS4sJyEf2VzWjI8uAavhxBQ== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.5" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.19.0" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.20.5" + "@babel/types" "^7.20.5" + debug "^4.1.0" + globals "^11.1.0" + +"@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.5.tgz#e206ae370b5393d94dfd1d04cd687cace53efa84" + integrity sha512-c9fst/h2/dcF7H+MJKZ2T0KjEQ8hY/BNnDk/H3XY8C4Aw/eWQXWn/lWntHF9ooUBnGmEvbfGrTgLWc+um0YDUg== + dependencies: + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" + to-fast-properties "^2.0.0" + +"@jridgewell/gen-mapping@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" + integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== + dependencies: + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@jridgewell/gen-mapping@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" + integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== + dependencies: + "@jridgewell/set-array" "^1.0.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" + +"@jridgewell/resolve-uri@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== + +"@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== + +"@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/trace-mapping@^0.3.9": + version "0.3.17" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" + integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== + dependencies: + "@jridgewell/resolve-uri" "3.1.0" + "@jridgewell/sourcemap-codec" "1.4.14" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== dependencies: "@nodelib/fs.stat" "2.0.5" @@ -12,32 +332,89 @@ "@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== "@nodelib/fs.walk@^1.2.3": version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + resolved "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz" integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== dependencies: "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@rollup/plugin-babel@^5.3.1": + version "5.3.1" + resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" + integrity sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q== + dependencies: + "@babel/helper-module-imports" "^7.10.4" + "@rollup/pluginutils" "^3.1.0" + +"@rollup/plugin-commonjs@^21.0.1": + version "21.1.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553" + integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA== + dependencies: + "@rollup/pluginutils" "^3.1.0" + commondir "^1.0.1" + estree-walker "^2.0.1" + glob "^7.1.6" + is-reference "^1.2.1" + magic-string "^0.25.7" + resolve "^1.17.0" + +"@rollup/plugin-node-resolve@^13.1.1": + version "13.3.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz#da1c5c5ce8316cef96a2f823d111c1e4e498801c" + integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw== + dependencies: + "@rollup/pluginutils" "^3.1.0" + "@types/resolve" "1.17.1" + deepmerge "^4.2.2" + is-builtin-module "^3.1.0" + is-module "^1.0.0" + resolve "^1.19.0" + +"@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" + integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== + dependencies: + "@types/estree" "0.0.39" + estree-walker "^1.0.1" + picomatch "^2.2.2" + +"@scure/base@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" + integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== + "@sindresorhus/is@^4.0.0": version "4.6.0" - resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" + resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== "@szmarczak/http-timer@^4.0.5": version "4.0.6" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" + resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz" integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== dependencies: defer-to-connect "^2.0.0" +"@ts-morph/common@~0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.17.0.tgz#de0d405df10857907469fef8d9363893b4163fd1" + integrity sha512-RMSSvSfs9kb0VzkvQ2NWobwnj7TxCA9vI/IjR9bDHqgAyVbu2T0DN4wiKVqomyDWqO7dPr/tErSfq7urQ1Q37g== + dependencies: + fast-glob "^3.2.11" + minimatch "^5.1.0" + mkdirp "^1.0.4" + path-browserify "^1.0.1" + "@types/cacheable-request@^6.0.1": version "6.0.2" - resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz#c324da0197de0a98a2312156536ae262429ff6b9" + resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz" integrity sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA== dependencies: "@types/http-cache-semantics" "*" @@ -45,48 +422,65 @@ "@types/node" "*" "@types/responselike" "*" +"@types/estree@*": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" + integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== + +"@types/estree@0.0.39": + version "0.0.39" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" + integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== + "@types/http-cache-semantics@*": version "4.0.1" - resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" + resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz" integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== "@types/json-buffer@~3.0.0": version "3.0.0" - resolved "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz#85c1ff0f0948fc159810d4b5be35bf8c20875f64" + resolved "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz" integrity sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ== "@types/keyv@*": version "3.1.4" - resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6" + resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz" integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== dependencies: "@types/node" "*" "@types/node@*": version "18.0.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a" + resolved "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz" integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA== +"@types/resolve@1.17.1": + version "1.17.1" + resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" + integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== + dependencies: + "@types/node" "*" + "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" - resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" + resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== dependencies: "@types/node" "*" acorn-walk@^8.2.0: version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== acorn@^8.7.1: version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" + resolved "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz" integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== aggregate-error@^3.0.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" + resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz" integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== dependencies: clean-stack "^2.0.0" @@ -94,7 +488,7 @@ aggregate-error@^3.0.0: aggregate-error@^4.0.0: version "4.0.1" - resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-4.0.1.tgz#25091fe1573b9e0be892aeda15c7c66a545f758e" + resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-4.0.1.tgz" integrity sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w== dependencies: clean-stack "^4.0.0" @@ -102,36 +496,36 @@ aggregate-error@^4.0.0: ansi-regex@^5.0.1: version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== ansi-regex@^6.0.1: version "6.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz" integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== ansi-styles@^3.2.1: version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" ansi-styles@^4.0.0: version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: color-convert "^2.0.1" ansi-styles@^6.0.0, ansi-styles@^6.1.0: version "6.1.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.1.0.tgz#87313c102b8118abd57371afab34618bf7350ed3" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz" integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== anymatch@~3.1.2: version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" + resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz" integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== dependencies: normalize-path "^3.0.0" @@ -139,34 +533,39 @@ anymatch@~3.1.2: argparse@^1.0.7: version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== dependencies: sprintf-js "~1.0.2" array-find-index@^1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + resolved "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz" integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== array-union@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + resolved "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== arrgv@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/arrgv/-/arrgv-1.0.2.tgz#025ed55a6a433cad9b604f8112fc4292715a6ec0" + resolved "https://registry.npmjs.org/arrgv/-/arrgv-1.0.2.tgz" integrity sha512-a4eg4yhp7mmruZDQFqVMlxNRFGi/i1r87pt8SDHy0/I8PqSXoUTlWZRdAZo0VXgvEARcujbtTk8kiZRi1uDGRw== arrify@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-3.0.0.tgz#ccdefb8eaf2a1d2ab0da1ca2ce53118759fd46bc" + resolved "https://registry.npmjs.org/arrify/-/arrify-3.0.0.tgz" integrity sha512-tLkvA81vQG/XqE2mjDkGQHoOINtMHtysSnemrmoGe6PydDPMRbVugqyk4A6V/WDWEfm3l+0d8anA9r8cv/5Jaw== +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + ava@^4.2.0: version "4.3.0" - resolved "https://registry.yarnpkg.com/ava/-/ava-4.3.0.tgz#e9466990caba63789eac3a0013714ea76dd82463" + resolved "https://registry.npmjs.org/ava/-/ava-4.3.0.tgz" integrity sha512-Ap0u8rp8wOBN6CxshgxrPSe191e8g52RWGoXeDB57ubo4fyZyStfI6OxQi/bl0yxIDEOYHhCiGwihbzlMNJw3Q== dependencies: acorn "^8.7.1" @@ -217,44 +616,44 @@ ava@^4.2.0: balanced-match@^1.0.0: version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== base-x@^3.0.2: version "3.0.9" - resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" + resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz" integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== dependencies: safe-buffer "^5.0.1" base64url@^3.0.1: version "3.0.1" - resolved "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" + resolved "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz" integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== binary-extensions@^2.0.0: version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== blueimp-md5@^2.10.0: version "2.19.0" - resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.19.0.tgz#b53feea5498dcb53dc6ec4b823adb84b729c4af0" + resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz" integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w== bn.js@5.2.0: version "5.2.0" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz" integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== bn.js@^5.2.0: version "5.2.1" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== borsh@^0.5.0: version "0.5.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.5.0.tgz#d5eed021a34118908d672295819e3c9e44f692ce" + resolved "https://registry.npmjs.org/borsh/-/borsh-0.5.0.tgz" integrity sha512-p9w/qGBeeFdUf2GPBPHdX5JQyez8K5VtoFN7PqSfmR+cVUMSmcwAKhP9n2aXoDSKbtS7xZlZt3MVnrJL7GdYhg== dependencies: bn.js "^5.2.0" @@ -263,7 +662,7 @@ borsh@^0.5.0: borsh@^0.6.0: version "0.6.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.6.0.tgz#a7c9eeca6a31ca9e0607cb49f329cb659eb791e1" + resolved "https://registry.npmjs.org/borsh/-/borsh-0.6.0.tgz" integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== dependencies: bn.js "^5.2.0" @@ -272,34 +671,56 @@ borsh@^0.6.0: brace-expansion@^1.1.7: version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.2, braces@~3.0.2: version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" +browserslist@^4.21.3: + version "4.21.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987" + integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw== + dependencies: + caniuse-lite "^1.0.30001400" + electron-to-chromium "^1.4.251" + node-releases "^2.0.6" + update-browserslist-db "^1.0.9" + bs58@^4.0.0, bs58@^4.0.1: version "4.0.1" - resolved "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + resolved "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz" integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== dependencies: base-x "^3.0.2" +builtin-modules@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" + integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== + cacheable-lookup@^5.0.3: version "5.0.4" - resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" + resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz" integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== cacheable-request@^7.0.2: version "7.0.2" - resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27" + resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz" integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== dependencies: clone-response "^1.0.2" @@ -312,7 +733,7 @@ cacheable-request@^7.0.2: call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + resolved "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz" integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== dependencies: function-bind "^1.1.1" @@ -320,22 +741,27 @@ call-bind@^1.0.0, call-bind@^1.0.2: callsites@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-4.0.0.tgz#8014cea4fedfe681a30e2f7d2d557dd95808a92a" + resolved "https://registry.npmjs.org/callsites/-/callsites-4.0.0.tgz" integrity sha512-y3jRROutgpKdz5vzEhWM34TidDU8vkJppF8dszITeb1PQmSqV3DTxyV8G/lyO/DNvtE1YTedehmw9MPZsCBHxQ== +caniuse-lite@^1.0.30001400: + version "1.0.30001435" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001435.tgz#502c93dbd2f493bee73a408fe98e98fb1dad10b2" + integrity sha512-kdCkUTjR+v4YAJelyiDTqiu82BDr4W4CP5sgTA0ZBmqn30XfS2ZghPLMowik9TPhS+psWJiUNxsqLyurDbmutA== + capability@^0.2.5: version "0.2.5" - resolved "https://registry.npmjs.org/capability/-/capability-0.2.5.tgz#51ad87353f1936ffd77f2f21c74633a4dea88801" + resolved "https://registry.npmjs.org/capability/-/capability-0.2.5.tgz" integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== cbor@^8.1.0: version "8.1.0" - resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" + resolved "https://registry.npmjs.org/cbor/-/cbor-8.1.0.tgz" integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== dependencies: nofilter "^3.1.0" -chalk@^2.4.1: +chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -346,12 +772,12 @@ chalk@^2.4.1: chalk@^5.0.1: version "5.0.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + resolved "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz" integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== chokidar@^3.5.3: version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== dependencies: anymatch "~3.1.2" @@ -366,44 +792,44 @@ chokidar@^3.5.3: chownr@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" + resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== chunkd@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/chunkd/-/chunkd-2.0.1.tgz#49cd1d7b06992dc4f7fccd962fe2a101ee7da920" + resolved "https://registry.npmjs.org/chunkd/-/chunkd-2.0.1.tgz" integrity sha512-7d58XsFmOq0j6el67Ug9mHf9ELUXsQXYJBkyxhH/k+6Ke0qXRnv0kbemx+Twc6fRJ07C49lcbdgm9FL1Ei/6SQ== ci-info@^3.3.1: version "3.3.2" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128" + resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz" integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg== ci-parallel-vars@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/ci-parallel-vars/-/ci-parallel-vars-1.0.1.tgz#e87ff0625ccf9d286985b29b4ada8485ca9ffbc2" + resolved "https://registry.npmjs.org/ci-parallel-vars/-/ci-parallel-vars-1.0.1.tgz" integrity sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg== clean-stack@^2.0.0: version "2.2.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== clean-stack@^4.0.0: version "4.2.0" - resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-4.2.0.tgz#c464e4cde4ac789f4e0735c5d75beb49d7b30b31" + resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz" integrity sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg== dependencies: escape-string-regexp "5.0.0" clean-yaml-object@^0.1.0: version "0.1.0" - resolved "https://registry.yarnpkg.com/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz#63fb110dc2ce1a84dc21f6d9334876d010ae8b68" + resolved "https://registry.npmjs.org/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz" integrity sha512-3yONmlN9CSAkzNwnRCiJQ7Q2xK5mWuEfL3PuTZcAUzhObbXsfsnMptJzXwz93nc5zn9V9TwCVMmV7w4xsm43dw== cli-truncate@^3.1.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-3.1.0.tgz#3f23ab12535e3d73e839bb43e73c9de487db1389" + resolved "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz" integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== dependencies: slice-ansi "^5.0.0" @@ -411,7 +837,7 @@ cli-truncate@^3.1.0: cliui@^7.0.2: version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz" integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== dependencies: string-width "^4.2.0" @@ -420,50 +846,65 @@ cliui@^7.0.2: clone-response@^1.0.2: version "1.0.3" - resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz#af2032aa47816399cf5f0a1d0db902f517abb8c3" + resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz" integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== dependencies: mimic-response "^1.0.0" +code-block-writer@^11.0.3: + version "11.0.3" + resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-11.0.3.tgz#9eec2993edfb79bfae845fbc093758c0a0b73b76" + integrity sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw== + code-excerpt@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/code-excerpt/-/code-excerpt-4.0.0.tgz#2de7d46e98514385cb01f7b3b741320115f4c95e" + resolved "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz" integrity sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA== dependencies: convert-to-spaces "^2.0.1" color-convert@^1.9.0: version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== dependencies: color-name "1.1.3" color-convert@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== dependencies: color-name "~1.1.4" color-name@1.1.3: version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== color-name@~1.1.4: version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +commander@^9.4.1: + version "9.4.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd" + integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw== + common-path-prefix@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0" + resolved "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz" integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w== +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== + compress-brotli@^1.3.8: version "1.3.8" - resolved "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz#0c0a60c97a989145314ec381e84e26682e7b38db" + resolved "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz" integrity sha512-lVcQsjhxhIXsuupfy9fmZUFtAIdBmXA7EGY6GBdgZ++qkM9zG4YFT8iU7FoBxzryNDMOpD1HIFHUSX4D87oqhQ== dependencies: "@types/json-buffer" "~3.0.0" @@ -471,12 +912,12 @@ compress-brotli@^1.3.8: concat-map@0.0.1: version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== concordance@^5.0.4: version "5.0.4" - resolved "https://registry.yarnpkg.com/concordance/-/concordance-5.0.4.tgz#9896073261adced72f88d60e4d56f8efc4bbbbd2" + resolved "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz" integrity sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw== dependencies: date-time "^3.1.0" @@ -488,14 +929,19 @@ concordance@^5.0.4: semver "^7.3.2" well-known-symbols "^2.0.0" +convert-source-map@^1.7.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== + convert-to-spaces@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz#61a6c98f8aa626c16b296b862a91412a33bceb6b" + resolved "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz" integrity sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ== cross-spawn@^6.0.5: version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz" integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== dependencies: nice-try "^1.0.4" @@ -506,40 +952,50 @@ cross-spawn@^6.0.5: currently-unhandled@^0.4.1: version "0.4.1" - resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + resolved "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz" integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== dependencies: array-find-index "^1.0.1" date-time@^3.1.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/date-time/-/date-time-3.1.0.tgz#0d1e934d170579f481ed8df1e2b8ff70ee845e1e" + resolved "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz" integrity sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg== dependencies: time-zone "^1.0.0" -debug@^4.3.4: +debug@^4.1.0, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og== + decompress-response@^6.0.0: version "6.0.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" + resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz" integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== dependencies: mimic-response "^3.1.0" +deepmerge@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" + integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== + defer-to-connect@^2.0.0: version "2.0.1" - resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" + resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz" integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== define-properties@^1.1.3, define-properties@^1.1.4: version "1.1.4" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" + resolved "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz" integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== dependencies: has-property-descriptors "^1.0.0" @@ -547,7 +1003,7 @@ define-properties@^1.1.3, define-properties@^1.1.4: del@^6.1.1: version "6.1.1" - resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a" + resolved "https://registry.npmjs.org/del/-/del-6.1.1.tgz" integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg== dependencies: globby "^11.0.1" @@ -561,58 +1017,63 @@ del@^6.1.1: depd@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== depd@~1.1.2: version "1.1.2" - resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== dir-glob@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + resolved "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz" integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== dependencies: path-type "^4.0.0" eastasianwidth@^0.2.0: version "0.2.0" - resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz" integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== +electron-to-chromium@^1.4.251: + version "1.4.284" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592" + integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA== + emittery@^0.11.0: version "0.11.0" - resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.11.0.tgz#eb5f756a200d3431de2c6e850cb2d8afd97a03b9" + resolved "https://registry.npmjs.org/emittery/-/emittery-0.11.0.tgz" integrity sha512-S/7tzL6v5i+4iJd627Nhv9cLFIo5weAIlGccqJFpnBoDB8U1TF2k5tez4J/QNuxyyhWuFqHg1L84Kd3m7iXg6g== emoji-regex@^8.0.0: version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== emoji-regex@^9.2.2: version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz" integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== end-of-stream@^1.1.0: version "1.4.4" - resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== dependencies: once "^1.4.0" error-ex@^1.3.1: version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + resolved "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz" integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== dependencies: is-arrayish "^0.2.1" error-polyfill@^0.1.3: version "0.1.3" - resolved "https://registry.npmjs.org/error-polyfill/-/error-polyfill-0.1.3.tgz#df848b61ad8834f7a5db69a70b9913df86721d15" + resolved "https://registry.npmjs.org/error-polyfill/-/error-polyfill-0.1.3.tgz" integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== dependencies: capability "^0.2.5" @@ -621,7 +1082,7 @@ error-polyfill@^0.1.3: es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.5: version "1.20.4" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.4.tgz#1d103f9f8d78d4cf0713edcd6d0ed1a46eed5861" + resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz" integrity sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA== dependencies: call-bind "^1.0.2" @@ -651,7 +1112,7 @@ es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.5: es-to-primitive@^1.2.1: version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + resolved "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz" integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== dependencies: is-callable "^1.1.4" @@ -660,42 +1121,52 @@ es-to-primitive@^1.2.1: escalade@^3.1.1: version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== escape-string-regexp@5.0.0, escape-string-regexp@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz" integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== escape-string-regexp@^1.0.5: version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== escape-string-regexp@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== esprima@^4.0.0: version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== +estree-walker@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" + integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + +estree-walker@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== + esutils@^2.0.3: version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== fast-diff@^1.2.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + resolved "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== fast-glob@^3.2.11, fast-glob@^3.2.9: version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz" integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== dependencies: "@nodelib/fs.stat" "^2.0.2" @@ -706,14 +1177,21 @@ fast-glob@^3.2.11, fast-glob@^3.2.9: fastq@^1.6.0: version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" + resolved "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz" integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== dependencies: reusify "^1.0.4" +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + integrity sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA== + dependencies: + escape-string-regexp "^1.0.5" + figures@^4.0.1: version "4.0.1" - resolved "https://registry.yarnpkg.com/figures/-/figures-4.0.1.tgz#27b26609907bc888b3e3b0ef5403643f80aa2518" + resolved "https://registry.npmjs.org/figures/-/figures-4.0.1.tgz" integrity sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w== dependencies: escape-string-regexp "^5.0.0" @@ -721,14 +1199,21 @@ figures@^4.0.1: fill-range@^7.0.1: version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== dependencies: to-regex-range "^5.0.1" +find-up@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ== + dependencies: + locate-path "^2.0.0" + find-up@^6.0.0: version "6.3.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-6.3.0.tgz#2abab3d3280b2dc7ac10199ef324c4e002c8c790" + resolved "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz" integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw== dependencies: locate-path "^7.1.0" @@ -736,7 +1221,7 @@ find-up@^6.0.0: fs-extra@^10.0.0: version "10.1.0" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz" integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== dependencies: graceful-fs "^4.2.0" @@ -745,14 +1230,14 @@ fs-extra@^10.0.0: fs-minipass@^2.0.0: version "2.1.0" - resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" + resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz" integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== dependencies: minipass "^3.0.0" fs.realpath@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: @@ -762,12 +1247,12 @@ fsevents@~2.3.2: function-bind@^1.1.1: version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== function.prototype.name@^1.1.5: version "1.1.5" - resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + resolved "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz" integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== dependencies: call-bind "^1.0.2" @@ -777,17 +1262,22 @@ function.prototype.name@^1.1.5: functions-have-names@^1.2.2: version "1.2.3" - resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + resolved "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz" integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== +gensync@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== + get-caller-file@^2.0.5: version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3: version "1.1.3" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385" + resolved "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz" integrity sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A== dependencies: function-bind "^1.1.1" @@ -796,14 +1286,14 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1, get-intrinsic@ get-stream@^5.1.0: version "5.2.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" + resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== dependencies: pump "^3.0.0" get-symbol-description@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6" + resolved "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz" integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== dependencies: call-bind "^1.0.2" @@ -811,12 +1301,12 @@ get-symbol-description@^1.0.0: glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@^7.1.3: +glob@^7.1.3, glob@^7.1.6: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -828,9 +1318,14 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +globals@^11.1.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + globby@^11.0.1: version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: array-union "^2.1.0" @@ -842,7 +1337,7 @@ globby@^11.0.1: globby@^13.1.1: version "13.1.2" - resolved "https://registry.yarnpkg.com/globby/-/globby-13.1.2.tgz#29047105582427ab6eca4f905200667b056da515" + resolved "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz" integrity sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ== dependencies: dir-glob "^3.0.1" @@ -853,7 +1348,7 @@ globby@^13.1.1: got@^11.8.2: version "11.8.5" - resolved "https://registry.npmjs.org/got/-/got-11.8.5.tgz#ce77d045136de56e8f024bebb82ea349bc730046" + resolved "https://registry.npmjs.org/got/-/got-11.8.5.tgz" integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ== dependencies: "@sindresorhus/is" "^4.0.0" @@ -870,58 +1365,58 @@ got@^11.8.2: graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== has-bigints@^1.0.1, has-bigints@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + resolved "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz" integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== has-flag@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== has-property-descriptors@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + resolved "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz" integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== dependencies: get-intrinsic "^1.1.1" has-symbols@^1.0.2, has-symbols@^1.0.3: version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + resolved "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== has-tostringtag@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" + resolved "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz" integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== dependencies: has-symbols "^1.0.2" has@^1.0.3: version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: function-bind "^1.1.1" hosted-git-info@^2.1.4: version "2.8.9" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz" integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== http-cache-semantics@^4.0.0: version "4.1.0" - resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" + resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== http-errors@^1.7.2: version "1.8.1" - resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" + resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz" integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== dependencies: depd "~1.1.2" @@ -932,7 +1427,7 @@ http-errors@^1.7.2: http2-wrapper@^1.0.0-beta.5.2: version "1.0.3" - resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d" + resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz" integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== dependencies: quick-lru "^5.1.1" @@ -940,32 +1435,32 @@ http2-wrapper@^1.0.0-beta.5.2: ignore-by-default@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-2.1.0.tgz#c0e0de1a99b6065bdc93315a6f728867981464db" + resolved "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-2.1.0.tgz" integrity sha512-yiWd4GVmJp0Q6ghmM2B/V3oZGRmjrKLXvHR3TE1nfoXsmoggllfZUQe74EN0fJdPFZu2NIvNdrMMLm3OsV7Ohw== ignore@^5.2.0: version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== imurmurhash@^0.1.4: version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== indent-string@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" + resolved "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz" integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== indent-string@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-5.0.0.tgz#4fd2980fccaf8622d14c64d694f4cf33c81951a5" + resolved "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz" integrity sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg== inflight@^1.0.4: version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" @@ -973,12 +1468,12 @@ inflight@^1.0.4: inherits@2, inherits@2.0.4: version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== internal-slot@^1.0.3: version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" + resolved "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz" integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== dependencies: get-intrinsic "^1.1.0" @@ -987,122 +1482,141 @@ internal-slot@^1.0.3: irregular-plurals@^3.3.0: version "3.3.0" - resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.3.0.tgz#67d0715d4361a60d9fd9ee80af3881c631a31ee2" + resolved "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.3.0.tgz" integrity sha512-MVBLKUTangM3EfRPFROhmWQQKRDsrgI83J8GS3jXy+OwYqiR2/aoWndYQ5416jLE3uaGgLH7ncme3X9y09gZ3g== is-arrayish@^0.2.1: version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== is-bigint@^1.0.1: version "1.0.4" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3" + resolved "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz" integrity sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg== dependencies: has-bigints "^1.0.1" is-binary-path@~2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: binary-extensions "^2.0.0" is-boolean-object@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719" + resolved "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz" integrity sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA== dependencies: call-bind "^1.0.2" has-tostringtag "^1.0.0" +is-builtin-module@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-3.2.0.tgz#bb0310dfe881f144ca83f30100ceb10cf58835e0" + integrity sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw== + dependencies: + builtin-modules "^3.3.0" + is-callable@^1.1.4, is-callable@^1.2.7: version "1.2.7" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz" integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== is-core-module@^2.9.0: version "2.11.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz" integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== dependencies: has "^1.0.3" is-date-object@^1.0.1: version "1.0.5" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" + resolved "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz" integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== dependencies: has-tostringtag "^1.0.0" is-error@^2.2.2: version "2.2.2" - resolved "https://registry.yarnpkg.com/is-error/-/is-error-2.2.2.tgz#c10ade187b3c93510c5470a5567833ee25649843" + resolved "https://registry.npmjs.org/is-error/-/is-error-2.2.2.tgz" integrity sha512-IOQqts/aHWbiisY5DuPJQ0gcbvaLFCa7fBa9xoLfxBZvQ+ZI/Zh9xoI7Gk+G64N0FdK4AbibytHht2tWgpJWLg== is-extglob@^2.1.1: version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== is-fullwidth-code-point@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== is-fullwidth-code-point@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz" integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== is-glob@^4.0.1, is-glob@~4.0.1: version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: is-extglob "^2.1.1" +is-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" + integrity sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g== + is-negative-zero@^2.0.2: version "2.0.2" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + resolved "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz" integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== is-number-object@^1.0.4: version "1.0.7" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.7.tgz#59d50ada4c45251784e9904f5246c742f07a42fc" + resolved "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz" integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== dependencies: has-tostringtag "^1.0.0" is-number@^7.0.0: version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== is-path-cwd@^2.2.0: version "2.2.0" - resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" + resolved "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== is-path-inside@^3.0.2: version "3.0.3" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== is-plain-object@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz" integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== is-promise@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-4.0.0.tgz#42ff9f84206c1991d26debf520dd5c01042dd2f3" + resolved "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz" integrity sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ== +is-reference@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" + integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== + dependencies: + "@types/estree" "*" + is-regex@^1.1.4: version "1.1.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" + resolved "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz" integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== dependencies: call-bind "^1.0.2" @@ -1110,73 +1624,88 @@ is-regex@^1.1.4: is-shared-array-buffer@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + resolved "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz" integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== dependencies: call-bind "^1.0.2" is-string@^1.0.5, is-string@^1.0.7: version "1.0.7" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" + resolved "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz" integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== dependencies: has-tostringtag "^1.0.0" is-symbol@^1.0.2, is-symbol@^1.0.3: version "1.0.4" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" + resolved "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz" integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== dependencies: has-symbols "^1.0.2" is-unicode-supported@^1.2.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz#f4f54f34d8ebc84a46b93559a036763b6d3e1014" + resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz" integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ== is-weakref@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + resolved "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz" integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== dependencies: call-bind "^1.0.2" isexe@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== js-sha256@^0.9.0: version "0.9.0" - resolved "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" + resolved "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz" integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== js-string-escape@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" + resolved "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz" integrity sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg== +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + js-yaml@^3.14.1: version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz" integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== dependencies: argparse "^1.0.7" esprima "^4.0.0" +jsesc@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== + json-buffer@3.0.1, json-buffer@~3.0.1: version "3.0.1" - resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== json-parse-better-errors@^1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + resolved "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== +json5@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" + integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + jsonfile@^6.0.1: version "6.1.0" - resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz" integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== dependencies: universalify "^2.0.0" @@ -1185,7 +1714,7 @@ jsonfile@^6.0.1: keyv@^4.0.0: version "4.3.3" - resolved "https://registry.npmjs.org/keyv/-/keyv-4.3.3.tgz#6c1bcda6353a9e96fc1b4e1aeb803a6e35090ba9" + resolved "https://registry.npmjs.org/keyv/-/keyv-4.3.3.tgz" integrity sha512-AcysI17RvakTh8ir03+a3zJr5r0ovnAH/XTXei/4HIv3bL2K/jzvgivLK9UuI/JbU1aJjM3NSAnVvVVd3n+4DQ== dependencies: compress-brotli "^1.3.8" @@ -1193,7 +1722,7 @@ keyv@^4.0.0: load-json-file@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz" integrity sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw== dependencies: graceful-fs "^4.1.2" @@ -1203,57 +1732,72 @@ load-json-file@^4.0.0: load-json-file@^7.0.0: version "7.0.1" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-7.0.1.tgz#a3c9fde6beffb6bedb5acf104fad6bb1604e1b00" + resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-7.0.1.tgz" integrity sha512-Gnxj3ev3mB5TkVBGad0JM6dmLiQL+o0t23JPBZ9sd+yvSLk05mFoqKBw5N8gbbkU4TNXyqCgIrl/VM17OgUIgQ== +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA== + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + locate-path@^7.1.0: version "7.1.1" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-7.1.1.tgz#8e1e5a75c7343770cef02ff93c4bf1f0aa666374" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-7.1.1.tgz" integrity sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg== dependencies: p-locate "^6.0.0" lodash@^4.17.15: version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== lowercase-keys@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz" integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== lru-cache@^6.0.0: version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== dependencies: yallist "^4.0.0" +magic-string@^0.25.7: + version "0.25.9" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" + integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== + dependencies: + sourcemap-codec "^1.4.8" + map-age-cleaner@^0.1.3: version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + resolved "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz" integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== dependencies: p-defer "^1.0.0" matcher@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/matcher/-/matcher-5.0.0.tgz#cd82f1c7ae7ee472a9eeaf8ec7cac45e0fe0da62" + resolved "https://registry.npmjs.org/matcher/-/matcher-5.0.0.tgz" integrity sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw== dependencies: escape-string-regexp "^5.0.0" md5-hex@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-3.0.1.tgz#be3741b510591434b2784d79e556eefc2c9a8e5c" + resolved "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz" integrity sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw== dependencies: blueimp-md5 "^2.10.0" mem@^9.0.2: version "9.0.2" - resolved "https://registry.yarnpkg.com/mem/-/mem-9.0.2.tgz#bbc2d40be045afe30749681e8f5d554cee0c0354" + resolved "https://registry.npmjs.org/mem/-/mem-9.0.2.tgz" integrity sha512-F2t4YIv9XQUBHt6AOJ0y7lSmP1+cY7Fm1DRh9GClTGzKST7UWLMx6ly9WZdLH/G/ppM5RL4MlQfRT71ri9t19A== dependencies: map-age-cleaner "^0.1.3" @@ -1261,17 +1805,17 @@ mem@^9.0.2: memorystream@^0.3.1: version "0.3.1" - resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + resolved "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz" integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== micromatch@^4.0.4: version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + resolved "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz" integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: braces "^3.0.2" @@ -1279,64 +1823,71 @@ micromatch@^4.0.4: mimic-fn@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz" integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== mimic-response@^1.0.0: version "1.0.1" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== mimic-response@^3.1.0: version "3.1.0" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" + resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== minimatch@^3.0.4, minimatch@^3.1.1: version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: brace-expansion "^1.1.7" +minimatch@^5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.1.tgz#6c9dffcf9927ff2a31e74b5af11adf8b9604b022" + integrity sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g== + dependencies: + brace-expansion "^2.0.1" + minipass@^3.0.0: version "3.3.4" - resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz#ca99f95dd77c43c7a76bf51e6d200025eee0ffae" + resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz" integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw== dependencies: yallist "^4.0.0" minizlib@^2.1.1: version "2.1.2" - resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" + resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== dependencies: minipass "^3.0.0" yallist "^4.0.0" -mkdirp@^1.0.3: +mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== ms@2.1.2: version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== ms@^2.1.3: version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== mustache@^4.0.0: version "4.2.0" - resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" + resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== near-api-js@^0.44.1: version "0.44.2" - resolved "https://registry.npmjs.org/near-api-js/-/near-api-js-0.44.2.tgz#e451f68f2c56bd885c7b918db5818a3e6e9423d0" + resolved "https://registry.npmjs.org/near-api-js/-/near-api-js-0.44.2.tgz" integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== dependencies: bn.js "5.2.0" @@ -1353,22 +1904,38 @@ near-api-js@^0.44.1: near-sandbox@^0.0.13: version "0.0.13" - resolved "https://registry.yarnpkg.com/near-sandbox/-/near-sandbox-0.0.13.tgz#139b70708ccefcdf2dd406710f6615590d1880e5" + resolved "https://registry.npmjs.org/near-sandbox/-/near-sandbox-0.0.13.tgz" integrity sha512-rtRn51BBD1oT9SeGAIInKVedfaS/i4VqKqznZIvFddWo0jcI4lMoK1yHuTVuEE7YfEE12NsspFG1GxN1SlPV2g== dependencies: got "^11.8.2" tar "^6.1.0" +"near-sdk-js@file:..": + version "0.6.0" + dependencies: + "@babel/core" "^7.17.5" + "@babel/plugin-proposal-decorators" "^7.17.2" + "@babel/preset-typescript" "^7.18.6" + "@rollup/plugin-babel" "^5.3.1" + "@rollup/plugin-commonjs" "^21.0.1" + "@rollup/plugin-node-resolve" "^13.1.1" + "@scure/base" "^1.1.1" + commander "^9.4.1" + rollup "^2.61.1" + rollup-plugin-sourcemaps "^0.6.3" + signale "^1.4.0" + ts-morph "^16.0.0" + near-units@^0.1.9: version "0.1.9" - resolved "https://registry.npmjs.org/near-units/-/near-units-0.1.9.tgz#4bf07da0b046e08e0b8785ad8e32d4df3a944b93" + resolved "https://registry.npmjs.org/near-units/-/near-units-0.1.9.tgz" integrity sha512-xiuBjpNsi+ywiu7P6iWRZdgFm7iCr/cfWlVO6+e5uaAqH4mE1rrurElyrL91llNDSnMwogd9XmlZOw5KbbHNsA== dependencies: bn.js "^5.2.0" near-workspaces@3.2.1: version "3.2.1" - resolved "https://registry.yarnpkg.com/near-workspaces/-/near-workspaces-3.2.1.tgz#38c33474ece5898323f10cff7c75f771bb5a991a" + resolved "https://registry.npmjs.org/near-workspaces/-/near-workspaces-3.2.1.tgz" integrity sha512-761D8lsbSetS+Nu9C4IWdONn0gBSVpfjY8V09AOQt1Zb5XjtURFWpFTZun6vQJhvWv5+RsSNTF6uYsLyTLJBAA== dependencies: base64url "^3.0.1" @@ -1389,29 +1956,34 @@ near-workspaces@3.2.1: nice-try@^1.0.4: version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== node-fetch@^2.6.1: version "2.6.7" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" node-port-check@^2.0.1: version "2.0.1" - resolved "https://registry.npmjs.org/node-port-check/-/node-port-check-2.0.1.tgz#72cae367d3ca906b0903b261ce818c297aade11f" + resolved "https://registry.npmjs.org/node-port-check/-/node-port-check-2.0.1.tgz" integrity sha512-PV1tj5OPbWwxvhPcChXxwCIKl/IfVEdPP4u/gQz2lao/VGoeIUXb/4U72KSHLZpTVBmgTnMm0me7yR0wUsIuPg== +node-releases@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" + integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== + nofilter@^3.1.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-3.1.0.tgz#c757ba68801d41ff930ba2ec55bab52ca184aa66" + resolved "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz" integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== normalize-package-data@^2.3.2: version "2.5.0" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + resolved "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== dependencies: hosted-git-info "^2.1.4" @@ -1421,17 +1993,17 @@ normalize-package-data@^2.3.2: normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== normalize-url@^6.0.1: version "6.1.0" - resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" + resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz" integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== npm-run-all@^4.1.5: version "4.1.5" - resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" + resolved "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz" integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ== dependencies: ansi-styles "^3.2.1" @@ -1446,24 +2018,24 @@ npm-run-all@^4.1.5: o3@^1.0.3: version "1.0.3" - resolved "https://registry.npmjs.org/o3/-/o3-1.0.3.tgz#192ce877a882dfa6751f0412a865fafb2da1dac0" + resolved "https://registry.npmjs.org/o3/-/o3-1.0.3.tgz" integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== dependencies: capability "^0.2.5" object-inspect@^1.12.2, object-inspect@^1.9.0: version "1.12.2" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" + resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz" integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== object-keys@^1.1.1: version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + resolved "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== object.assign@^4.1.4: version "4.1.4" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + resolved "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz" integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== dependencies: call-bind "^1.0.2" @@ -1473,64 +2045,83 @@ object.assign@^4.1.4: once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" p-cancelable@^2.0.0: version "2.1.1" - resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" + resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz" integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== p-defer@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + resolved "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz" integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw== p-event@^5.0.1: version "5.0.1" - resolved "https://registry.yarnpkg.com/p-event/-/p-event-5.0.1.tgz#614624ec02ae7f4f13d09a721c90586184af5b0c" + resolved "https://registry.npmjs.org/p-event/-/p-event-5.0.1.tgz" integrity sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ== dependencies: p-timeout "^5.0.2" +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + p-limit@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644" + resolved "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz" integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ== dependencies: yocto-queue "^1.0.0" +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg== + dependencies: + p-limit "^1.1.0" + p-locate@^6.0.0: version "6.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-6.0.0.tgz#3da9a49d4934b901089dca3302fa65dc5a05c04f" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz" integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw== dependencies: p-limit "^4.0.0" p-map@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + resolved "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz" integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== dependencies: aggregate-error "^3.0.0" p-map@^5.4.0: version "5.5.0" - resolved "https://registry.yarnpkg.com/p-map/-/p-map-5.5.0.tgz#054ca8ca778dfa4cf3f8db6638ccb5b937266715" + resolved "https://registry.npmjs.org/p-map/-/p-map-5.5.0.tgz" integrity sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg== dependencies: aggregate-error "^4.0.0" p-timeout@^5.0.2: version "5.1.0" - resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-5.1.0.tgz#b3c691cf4415138ce2d9cfe071dba11f0fee085b" + resolved "https://registry.npmjs.org/p-timeout/-/p-timeout-5.1.0.tgz" integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew== +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww== + parse-json@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + resolved "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz" integrity sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw== dependencies: error-ex "^1.3.1" @@ -1538,59 +2129,82 @@ parse-json@^4.0.0: parse-ms@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-2.1.0.tgz#348565a753d4391fa524029956b172cb7753097d" + resolved "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz" integrity sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA== +path-browserify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== + path-exists@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7" + resolved "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz" integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ== path-is-absolute@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-key@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + resolved "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz" integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== path-parse@^1.0.7: version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-type@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + resolved "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz" integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== dependencies: pify "^3.0.0" path-type@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.3.1: version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== pidtree@^0.3.0: version "0.3.1" - resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a" + resolved "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz" integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA== pify@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + resolved "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz" integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== +pkg-conf@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-2.1.0.tgz#2126514ca6f2abfebd168596df18ba57867f0058" + integrity sha512-C+VUP+8jis7EsQZIhDYmS5qlNtjv2yP4SNtjXK9AP1ZcTRlnSfuumaTnRfYZnYgUUYVIKqL0fRvmUGDV2fmp6g== + dependencies: + find-up "^2.0.0" + load-json-file "^4.0.0" + pkg-conf@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-4.0.0.tgz#63ace00cbacfa94c2226aee133800802d3e3b80c" + resolved "https://registry.npmjs.org/pkg-conf/-/pkg-conf-4.0.0.tgz" integrity sha512-7dmgi4UY4qk+4mj5Cd8v/GExPo0K+SlY+hulOSdfZ/T6jVH6//y7NtzZo5WrfhDBxuQ0jCa7fLZmNaNh7EWL/w== dependencies: find-up "^6.0.0" @@ -1598,26 +2212,26 @@ pkg-conf@^4.0.0: plur@^5.1.0: version "5.1.0" - resolved "https://registry.yarnpkg.com/plur/-/plur-5.1.0.tgz#bff58c9f557b9061d60d8ebf93959cf4b08594ae" + resolved "https://registry.npmjs.org/plur/-/plur-5.1.0.tgz" integrity sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg== dependencies: irregular-plurals "^3.3.0" pretty-ms@^7.0.1: version "7.0.1" - resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-7.0.1.tgz#7d903eaab281f7d8e03c66f867e239dc32fb73e8" + resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz" integrity sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q== dependencies: parse-ms "^2.1.0" promisify-child-process@^4.1.1: version "4.1.1" - resolved "https://registry.npmjs.org/promisify-child-process/-/promisify-child-process-4.1.1.tgz#290659e079f9c7bd46708404d4488a1a6b802686" + resolved "https://registry.npmjs.org/promisify-child-process/-/promisify-child-process-4.1.1.tgz" integrity sha512-/sRjHZwoXf1rJ+8s4oWjYjGRVKNK1DUnqfRC1Zek18pl0cN6k3yJ1cCbqd0tWNe4h0Gr+SY4vR42N33+T82WkA== pump@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== dependencies: end-of-stream "^1.1.0" @@ -1625,22 +2239,22 @@ pump@^3.0.0: pure-uuid@^1.6.2: version "1.6.2" - resolved "https://registry.npmjs.org/pure-uuid/-/pure-uuid-1.6.2.tgz#64f3032d54953b93b0585be3263a2629f1d60a04" + resolved "https://registry.npmjs.org/pure-uuid/-/pure-uuid-1.6.2.tgz" integrity sha512-WQ4xz74ApW6s0BToRuuyuMo9g0VHx1HljY0H2gPng+mqqz/K1yLj7sHZonZZQ2++WfHl/ZzruilWvuz+WtmxjQ== queue-microtask@^1.2.2: version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== quick-lru@^5.1.1: version "5.1.1" - resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" + resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== read-pkg@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz" integrity sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA== dependencies: load-json-file "^4.0.0" @@ -1649,14 +2263,14 @@ read-pkg@^3.0.0: readdirp@~3.6.0: version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== dependencies: picomatch "^2.2.1" regexp.prototype.flags@^1.4.3: version "1.4.3" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" + resolved "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz" integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== dependencies: call-bind "^1.0.2" @@ -1665,27 +2279,27 @@ regexp.prototype.flags@^1.4.3: require-directory@^2.1.1: version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== resolve-alpn@^1.0.0: version "1.2.1" - resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" + resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== resolve-cwd@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz" integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== dependencies: resolve-from "^5.0.0" resolve-from@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz" integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== -resolve@^1.10.0: +resolve@^1.10.0, resolve@^1.17.0, resolve@^1.19.0: version "1.22.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== @@ -1696,38 +2310,53 @@ resolve@^1.10.0: responselike@^2.0.0: version "2.0.1" - resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz#9a0bc8fdc252f3fb1cca68b016591059ba1422bc" + resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz" integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== dependencies: lowercase-keys "^2.0.0" reusify@^1.0.4: version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== rimraf@^3.0.2: version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: glob "^7.1.3" +rollup-plugin-sourcemaps@^0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed" + integrity sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw== + dependencies: + "@rollup/pluginutils" "^3.0.9" + source-map-resolve "^0.6.0" + +rollup@^2.61.1: + version "2.79.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7" + integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw== + optionalDependencies: + fsevents "~2.3.2" + run-parallel@^1.1.9: version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz" integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== dependencies: queue-microtask "^1.2.2" safe-buffer@^5.0.1: version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== safe-regex-test@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" + resolved "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz" integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== dependencies: call-bind "^1.0.2" @@ -1736,48 +2365,53 @@ safe-regex-test@^1.0.0: "semver@2 || 3 || 4 || 5", semver@^5.5.0: version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== +semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + semver@^7.3.2: version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz" integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: lru-cache "^6.0.0" serialize-error@^7.0.1: version "7.0.1" - resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-7.0.1.tgz#f1360b0447f61ffb483ec4157c737fab7d778e18" + resolved "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz" integrity sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw== dependencies: type-fest "^0.13.1" setprototypeof@1.2.0: version "1.2.0" - resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz" integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== shebang-command@^1.2.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz" integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== dependencies: shebang-regex "^1.0.0" shebang-regex@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz" integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== shell-quote@^1.6.1: version "1.7.4" - resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.4.tgz#33fe15dee71ab2a81fcbd3a52106c5cfb9fb75d8" + resolved "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.4.tgz" integrity sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw== side-channel@^1.0.4: version "1.0.4" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + resolved "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz" integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== dependencies: call-bind "^1.0.0" @@ -1786,30 +2420,52 @@ side-channel@^1.0.4: signal-exit@^3.0.7: version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/signale/-/signale-1.4.0.tgz#c4be58302fb0262ac00fc3d886a7c113759042f1" + integrity sha512-iuh+gPf28RkltuJC7W5MRi6XAjTDCAPC/prJUpQoG4vIP3MJZ+GTydVnodXA7pwvTKb2cA0m9OFZW/cdWy/I/w== + dependencies: + chalk "^2.3.2" + figures "^2.0.0" + pkg-conf "^2.1.0" + slash@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== slash@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" + resolved "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz" integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== slice-ansi@^5.0.0: version "5.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + resolved "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz" integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== dependencies: ansi-styles "^6.0.0" is-fullwidth-code-point "^4.0.0" +source-map-resolve@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" + integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + +sourcemap-codec@^1.4.8: + version "1.4.8" + resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" + integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== + spdx-correct@^3.0.0: version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz" integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== dependencies: spdx-expression-parse "^3.0.0" @@ -1817,12 +2473,12 @@ spdx-correct@^3.0.0: spdx-exceptions@^2.1.0: version "2.3.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + resolved "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz" integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== spdx-expression-parse@^3.0.0: version "3.0.1" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + resolved "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz" integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== dependencies: spdx-exceptions "^2.1.0" @@ -1830,29 +2486,29 @@ spdx-expression-parse@^3.0.0: spdx-license-ids@^3.0.0: version "3.0.12" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz#69077835abe2710b65f03969898b6637b505a779" + resolved "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz" integrity sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA== sprintf-js@~1.0.2: version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== stack-utils@^2.0.5: version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" + resolved "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz" integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== dependencies: escape-string-regexp "^2.0.0" "statuses@>= 1.5.0 < 2": version "1.5.0" - resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: emoji-regex "^8.0.0" @@ -1861,7 +2517,7 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: string-width@^5.0.0: version "5.1.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz" integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== dependencies: eastasianwidth "^0.2.0" @@ -1870,7 +2526,7 @@ string-width@^5.0.0: string.prototype.padend@^3.0.0: version "3.1.3" - resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.3.tgz#997a6de12c92c7cb34dc8a201a6c53d9bd88a5f1" + resolved "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.3.tgz" integrity sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg== dependencies: call-bind "^1.0.2" @@ -1879,7 +2535,7 @@ string.prototype.padend@^3.0.0: string.prototype.trimend@^1.0.5: version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz#914a65baaab25fbdd4ee291ca7dde57e869cb8d0" + resolved "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz" integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== dependencies: call-bind "^1.0.2" @@ -1888,7 +2544,7 @@ string.prototype.trimend@^1.0.5: string.prototype.trimstart@^1.0.5: version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz#5466d93ba58cfa2134839f81d7f42437e8c01fef" + resolved "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz" integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== dependencies: call-bind "^1.0.2" @@ -1897,26 +2553,26 @@ string.prototype.trimstart@^1.0.5: strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: ansi-regex "^5.0.1" strip-ansi@^7.0.1: version "7.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz" integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== dependencies: ansi-regex "^6.0.1" strip-bom@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz" integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== supertap@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/supertap/-/supertap-3.0.1.tgz#aa89e4522104402c6e8fe470a7d2db6dc4037c6a" + resolved "https://registry.npmjs.org/supertap/-/supertap-3.0.1.tgz" integrity sha512-u1ZpIBCawJnO+0QePsEiOknOfCRq0yERxiAchT0i4li0WHNUJbf0evXXSXOcCAR4M8iMDoajXYmstm/qO81Isw== dependencies: indent-string "^5.0.0" @@ -1926,19 +2582,19 @@ supertap@^3.0.1: supports-color@^5.3.0: version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== dependencies: has-flag "^3.0.0" supports-preserve-symlinks-flag@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== tar@^6.1.0: version "6.1.11" - resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== dependencies: chownr "^2.0.0" @@ -1950,59 +2606,72 @@ tar@^6.1.0: temp-dir@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-2.0.0.tgz#bde92b05bdfeb1516e804c9c00ad45177f31321e" + resolved "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz" integrity sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg== text-encoding-utf-8@^1.0.2: version "1.0.2" - resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" + resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz" integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== time-zone@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/time-zone/-/time-zone-1.0.0.tgz#99c5bf55958966af6d06d83bdf3800dc82faec5d" + resolved "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz" integrity sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA== +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== + to-regex-range@^5.0.1: version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: is-number "^7.0.0" toidentifier@1.0.1: version "1.0.1" - resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== tr46@~0.0.3: version "0.0.3" - resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== +ts-morph@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-16.0.0.tgz#35caca7c286dd70e09e5f72af47536bf3b6a27af" + integrity sha512-jGNF0GVpFj0orFw55LTsQxVYEUOCWBAbR5Ls7fTYE5pQsbW18ssTb/6UXx/GYAEjS+DQTp8VoTw0vqYMiaaQuw== + dependencies: + "@ts-morph/common" "~0.17.0" + code-block-writer "^11.0.3" + tweetnacl@^1.0.1: version "1.0.3" - resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz" integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== type-fest@^0.13.1: version "0.13.1" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" + resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz" integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== typescript@^4.7.4: version "4.7.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" + resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz" integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== u3@^0.1.1: version "0.1.1" - resolved "https://registry.npmjs.org/u3/-/u3-0.1.1.tgz#5f52044f42ee76cd8de33148829e14528494b73b" + resolved "https://registry.npmjs.org/u3/-/u3-0.1.1.tgz" integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== unbox-primitive@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + resolved "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz" integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== dependencies: call-bind "^1.0.2" @@ -2012,12 +2681,20 @@ unbox-primitive@^1.0.2: universalify@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== +update-browserslist-db@^1.0.9: + version "1.0.10" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" + integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" + validate-npm-package-license@^3.0.1: version "3.0.4" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + resolved "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz" integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== dependencies: spdx-correct "^3.0.0" @@ -2025,17 +2702,17 @@ validate-npm-package-license@^3.0.1: webidl-conversions@^3.0.0: version "3.0.1" - resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== well-known-symbols@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/well-known-symbols/-/well-known-symbols-2.0.0.tgz#e9c7c07dbd132b7b84212c8174391ec1f9871ba5" + resolved "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz" integrity sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q== whatwg-url@^5.0.0: version "5.0.0" - resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz" integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== dependencies: tr46 "~0.0.3" @@ -2043,7 +2720,7 @@ whatwg-url@^5.0.0: which-boxed-primitive@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" + resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz" integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== dependencies: is-bigint "^1.0.1" @@ -2054,14 +2731,14 @@ which-boxed-primitive@^1.0.2: which@^1.2.9: version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" wrap-ansi@^7.0.0: version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== dependencies: ansi-styles "^4.0.0" @@ -2070,12 +2747,12 @@ wrap-ansi@^7.0.0: wrappy@1: version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== write-file-atomic@^4.0.1: version "4.0.1" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.1.tgz#9faa33a964c1c85ff6f849b80b42a88c2c537c8f" + resolved "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.1.tgz" integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ== dependencies: imurmurhash "^0.1.4" @@ -2083,22 +2760,22 @@ write-file-atomic@^4.0.1: y18n@^5.0.5: version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== yallist@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== yargs-parser@^21.0.0: version "21.0.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35" + resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz" integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== yargs@^17.5.1: version "17.5.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e" + resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz" integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== dependencies: cliui "^7.0.2" @@ -2111,5 +2788,5 @@ yargs@^17.5.1: yocto-queue@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251" + resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz" integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== From 4adcb8f5f06f3016728dcae9865148489553dafc Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 2 Dec 2022 12:59:24 +0800 Subject: [PATCH 11/24] refactor utf8 and latin1 api --- lib/api.d.ts | 10 --- lib/api.js | 33 +------- lib/collections/lookup-map.js | 10 +-- lib/collections/lookup-set.js | 8 +- lib/collections/unordered-map.js | 10 +-- lib/collections/unordered-set.js | 18 ++--- lib/collections/vector.js | 4 +- lib/index.d.ts | 1 - lib/index.js | 1 - lib/near-bindgen.js | 10 +-- lib/types/public_key.js | 4 +- lib/utils.d.ts | 66 +++++++++++----- lib/utils.js | 106 +++++++++++++++----------- src/api.ts | 34 +-------- src/collections/lookup-map.ts | 10 +-- src/collections/lookup-set.ts | 8 +- src/collections/unordered-map.ts | 12 +-- src/collections/unordered-set.ts | 20 ++--- src/collections/vector.ts | 4 +- src/index.ts | 1 - src/near-bindgen.ts | 12 +-- src/types/public_key.ts | 4 +- src/utils.ts | 125 +++++++++++++++++++------------ 23 files changed, 260 insertions(+), 251 deletions(-) diff --git a/lib/api.d.ts b/lib/api.d.ts index 7ebe7f11c..d905af59d 100644 --- a/lib/api.d.ts +++ b/lib/api.d.ts @@ -355,13 +355,3 @@ export declare function altBn128G1Sum(value: Uint8Array): Uint8Array; * @returns whether pairing check pass */ export declare function altBn128PairingCheck(value: Uint8Array): boolean; -export declare class TextEncoder { - constructor(); - encode(s: string): Uint8Array; -} -export declare class TextDecoder { - encoding: string; - constructor(encoding?: string); - decode(a: Uint8Array): string; -} -export declare function bytes(s: string): Uint8Array; diff --git a/lib/api.js b/lib/api.js index eb43ac8b8..2a5ea7194 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,4 +1,4 @@ -import { assert, u8ArrayToLatin1, } from "./utils"; +import { assert, str, } from "./utils"; import { PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; const EVICTED_REGISTER = U64_MAX - 1n; @@ -25,7 +25,7 @@ export function log(...params) { */ export function signerAccountId() { env.signer_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** * Returns the public key of the account that signed the transaction. @@ -41,14 +41,14 @@ export function signerAccountPk() { */ export function predecessorAccountId() { env.predecessor_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** * Returns the account ID of the current contract - the contract that is being executed. */ export function currentAccountId() { env.current_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** * Returns the current block index. @@ -503,28 +503,3 @@ export function altBn128G1Sum(value) { export function altBn128PairingCheck(value) { return env.alt_bn128_pairing_check(value) === 1n; } -export class TextEncoder { - constructor() { } - encode(s) { - return env.utf8_string_to_uint8array(s); - } -} -export class TextDecoder { - constructor(encoding = 'utf-8') { - this.encoding = encoding; - } - decode(a) { - if (this.encoding == 'utf-8') { - return env.uint8array_to_utf8_string(a); - } - else if (this.encoding == 'latin1') { - return env.uint8array_to_latin1_string(a); - } - else { - throw new Error('unsupported encoding: ' + this.encoding); - } - } -} -export function bytes(s) { - return env.latin1_string_to_uint8array(s); -} diff --git a/lib/collections/lookup-map.js b/lib/collections/lookup-map.js index 52ef69db0..30f9c00f8 100644 --- a/lib/collections/lookup-map.js +++ b/lib/collections/lookup-map.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { getValueWithOptions, serializeValueWithOptions, u8ArrayConcat, } from "../utils"; +import { getValueWithOptions, serializeValueWithOptions, concat, } from "../utils"; /** * A lookup map that stores data in NEAR storage. */ @@ -16,7 +16,7 @@ export class LookupMap { * @param key - The value for which to check the presence. */ containsKey(key) { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); return near.storageHasKey(storageKey); } /** @@ -26,7 +26,7 @@ export class LookupMap { * @param options - Options for retrieving the data. */ get(key, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); const value = near.storageRead(storageKey); return getValueWithOptions(value, options); } @@ -37,7 +37,7 @@ export class LookupMap { * @param options - Options for retrieving the data. */ remove(key, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; } @@ -52,7 +52,7 @@ export class LookupMap { * @param options - Options for retrieving and storing the data. */ set(key, newValue, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); const storageValue = serializeValueWithOptions(newValue, options); if (!near.storageWrite(storageKey, storageValue)) { return options?.defaultValue ?? null; diff --git a/lib/collections/lookup-set.js b/lib/collections/lookup-set.js index 0b5a3eca6..88d31f7e2 100644 --- a/lib/collections/lookup-set.js +++ b/lib/collections/lookup-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { serializeValueWithOptions, u8ArrayConcat } from "../utils"; +import { serializeValueWithOptions, concat } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. */ @@ -17,7 +17,7 @@ export class LookupSet { * @param options - Options for storing data. */ contains(key, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); + const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); return near.storageHasKey(storageKey); } /** @@ -27,7 +27,7 @@ export class LookupSet { * @param options - Options for storing data. */ remove(key, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); + const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); return near.storageRemove(storageKey); } /** @@ -38,7 +38,7 @@ export class LookupSet { * @param options - Options for storing the data. */ set(key, options) { - const storageKey = u8ArrayConcat(this.keyPrefix, serializeValueWithOptions(key, options)); + const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); return !near.storageWrite(storageKey, new Uint8Array()); } /** diff --git a/lib/collections/unordered-map.js b/lib/collections/unordered-map.js index 09ea40d01..c2c04ef83 100644 --- a/lib/collections/unordered-map.js +++ b/lib/collections/unordered-map.js @@ -1,4 +1,4 @@ -import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, latin1ToU8Array, serializeValueWithOptions, u8ArrayConcat, } from "../utils"; +import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, bytes, serializeValueWithOptions, concat, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; /** @@ -10,8 +10,8 @@ export class UnorderedMap { */ constructor(prefix) { this.prefix = prefix; - this.keys = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("u"))); // intentional different prefix with old UnorderedMap - this.values = new LookupMap(u8ArrayConcat(prefix, latin1ToU8Array("m"))); + this.keys = new Vector(concat(prefix, bytes("u"))); // intentional different prefix with old UnorderedMap + this.values = new LookupMap(concat(prefix, bytes("m"))); } /** * The number of elements stored in the collection. @@ -144,10 +144,10 @@ export class UnorderedMap { static reconstruct(data) { const map = new UnorderedMap(data.prefix); // reconstruct keys Vector - map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array("u"))); + map.keys = new Vector(concat(data.prefix, bytes("u"))); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap(u8ArrayConcat(data.prefix, latin1ToU8Array("m"))); + map.values = new LookupMap(concat(data.prefix, bytes("m"))); return map; } } diff --git a/lib/collections/unordered-set.js b/lib/collections/unordered-set.js index 3b0c14c98..0b38fe00b 100644 --- a/lib/collections/unordered-set.js +++ b/lib/collections/unordered-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, u8ArrayConcat, latin1ToU8Array, } from "../utils"; +import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, concat, bytes } from "../utils"; import { Vector, VectorIterator } from "./vector"; function serializeIndex(index) { const data = new Uint32Array([index]); @@ -19,8 +19,8 @@ export class UnorderedSet { */ constructor(prefix) { this.prefix = prefix; - this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array("i")); - this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("e"))); + this.elementIndexPrefix = concat(prefix, bytes("i")); + this.elements = new Vector(concat(prefix, bytes("e"))); } /** * The number of elements stored in the collection. @@ -41,7 +41,7 @@ export class UnorderedSet { * @param options - Options for storing data. */ contains(element, options) { - const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); + const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); return near.storageHasKey(indexLookup); } /** @@ -52,7 +52,7 @@ export class UnorderedSet { * @param options - Options for storing the data. */ set(element, options) { - const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); + const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); if (near.storageRead(indexLookup)) { return false; } @@ -69,7 +69,7 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element, options) { - const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); + const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); const indexRaw = near.storageRead(indexLookup); if (!indexRaw) { return false; @@ -90,7 +90,7 @@ export class UnorderedSet { // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(lastElement, options)); + const lastLookupElement = concat(this.elementIndexPrefix, serializeValueWithOptions(lastElement, options)); near.storageWrite(lastLookupElement, indexRaw); } const index = deserializeIndex(indexRaw); @@ -102,7 +102,7 @@ export class UnorderedSet { */ clear(options) { for (const element of this.elements) { - const indexLookup = u8ArrayConcat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); + const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); near.storageRemove(indexLookup); } this.elements.clear(); @@ -159,7 +159,7 @@ export class UnorderedSet { static reconstruct(data) { const set = new UnorderedSet(data.prefix); // reconstruct Vector - const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array("e")); + const elementsPrefix = concat(data.prefix, bytes("e")); set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; return set; diff --git a/lib/collections/vector.js b/lib/collections/vector.js index 13acc1b06..c55910bcf 100644 --- a/lib/collections/vector.js +++ b/lib/collections/vector.js @@ -1,9 +1,9 @@ import * as near from "../api"; -import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, u8ArrayConcat, } from "../utils"; +import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, concat, } from "../utils"; function indexToKey(prefix, index) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return u8ArrayConcat(prefix, array); + return concat(prefix, array); } /** * An iterable implementation of vector that stores its content on the trie. diff --git a/lib/index.d.ts b/lib/index.d.ts index e3495d782..434577a5e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,5 +1,4 @@ export * as near from "./api"; -export { bytes } from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/lib/index.js b/lib/index.js index e3495d782..434577a5e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,4 @@ export * as near from "./api"; -export { bytes } from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/lib/near-bindgen.js b/lib/near-bindgen.js index 71b995a46..2eb14c9ae 100644 --- a/lib/near-bindgen.js +++ b/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, latin1ToU8Array, serialize, u8ArrayToLatin1, } from "./utils"; +import { deserialize, serialize, bytes, str } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * @@ -71,18 +71,18 @@ export function NearBindgen({ requireInit = false, serializer = serialize, deser return new target(); } static _getState() { - const rawState = near.storageRead(latin1ToU8Array("STATE")); + const rawState = near.storageRead(bytes("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave) { - near.storageWrite(latin1ToU8Array("STATE"), this._serialize(objectToSave)); + near.storageWrite(bytes("STATE"), this._serialize(objectToSave)); } static _getArgs() { - return JSON.parse(u8ArrayToLatin1(near.input()) || "{}"); + return JSON.parse(str(near.input()) || "{}"); } static _serialize(value, forReturn = false) { if (forReturn) { - return latin1ToU8Array(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value)); + return bytes(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value)); } return serializer(value); } diff --git a/lib/types/public_key.js b/lib/types/public_key.js index 39f8859c6..f778e20ce 100644 --- a/lib/types/public_key.js +++ b/lib/types/public_key.js @@ -1,5 +1,5 @@ import { base58 } from "@scure/base"; -import { u8ArrayConcat } from "../utils"; +import { concat } from "../utils"; export var CurveType; (function (CurveType) { CurveType[CurveType["ED25519"] = 0] = "ED25519"; @@ -108,6 +108,6 @@ export class PublicKey { catch (error) { throw new Base58Error(error.message); } - return new PublicKey(u8ArrayConcat(new Uint8Array([curve]), data)); + return new PublicKey(concat(new Uint8Array([curve]), data)); } } diff --git a/lib/utils.d.ts b/lib/utils.d.ts index bf1bdcfbd..d1eac0470 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -1,4 +1,10 @@ import { GetOptions } from "./types/collections"; +export interface Env { + uint8array_to_latin1_string(a: Uint8Array): string; + uint8array_to_utf8_string(a: Uint8Array): string; + latin1_string_to_uint8array(s: string): Uint8Array; + utf8_string_to_uint8array(s: string): Uint8Array; +} declare enum PromiseIndexBrand { _ = -1 } @@ -16,32 +22,13 @@ export declare type NearAmount = number | bigint; export declare type Register = number | bigint; export declare const ERR_INCONSISTENT_STATE = "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?"; export declare const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; -/** - * Convert a Uint8Array to string, use Latin1 encoding - * @param array - Uint8Array to convert - * @returns result string - */ -export declare function u8ArrayToLatin1(array: Uint8Array): string; -/** - * Convert a Latin1 string to Uint8Array - * @param latin1 - string that with only Latin1 character to convert - * @returns result Uint8Array - */ -export declare function latin1ToU8Array(latin1: string): Uint8Array; -/** - * Alias to latin1ToU8Array - */ -/** - * Alias to u8ArrayToLatin1 - */ -export declare function str(a: Uint8Array): string; /** * Concat two Uint8Array * @param array1 * @param array2 * @returns the concatenation of two array */ -export declare function u8ArrayConcat(array1: Uint8Array, array2: Uint8Array): Uint8Array; +export declare function concat(array1: Uint8Array, array2: Uint8Array): Uint8Array; /** * Asserts that the expression passed to the function is truthy, otherwise throws a new Error with the provided message. * @@ -63,4 +50,43 @@ export declare function deserialize(valueToDeserialize: Uint8Array): unknown; * @param accountId - The Account ID string you want to validate. */ export declare function validateAccountId(accountId: string): boolean; +/** + * A subset of NodeJS TextEncoder API + */ +export declare class TextEncoder { + constructor(); + encode(s: string): Uint8Array; +} +/** + * A subset of NodeJS TextDecoder API. Only support utf-8 and latin1 encoding. + */ +export declare class TextDecoder { + encoding: string; + constructor(encoding?: string); + decode(a: Uint8Array): string; +} +/** + * Convert a string to Uint8Array, each character must have a char code between 0-255. + * @param s - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export declare function bytes(s: string): Uint8Array; +/** + * Convert a Uint8Array to string, each uint8 to the single character of that char code + * @param a - Uint8Array to convert + * @returns result string + */ +export declare function str(a: Uint8Array): string; +/** + * Encode the string to Uint8Array with UTF-8 encoding + * @param s - String to encode + * @returns result Uint8Array + */ +export declare function encode(s: string): Uint8Array; +/** + * Decode the Uint8Array to string in UTF-8 encoding + * @param a - array to decode + * @returns result string + */ +export declare function decode(a: Uint8Array): string; export {}; diff --git a/lib/utils.js b/lib/utils.js index 7e0302248..fb7f923a2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,53 +12,13 @@ var TypeBrand; export const ERR_INCONSISTENT_STATE = "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?"; export const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; const ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/; -/** - * Convert a Uint8Array to string, use Latin1 encoding - * @param array - Uint8Array to convert - * @returns result string - */ -export function u8ArrayToLatin1(array) { - let ret = ""; - for (const e of array) { - ret += String.fromCharCode(e); - } - return ret; -} -/** - * Convert a Latin1 string to Uint8Array - * @param latin1 - string that with only Latin1 character to convert - * @returns result Uint8Array - */ -export function latin1ToU8Array(latin1) { - const ret = new Uint8Array(latin1.length); - for (let i = 0; i < latin1.length; i++) { - const code = latin1.charCodeAt(i); - if (code > 255) { - throw new Error(`string at index ${i}: ${latin1[i]} is not a valid latin1 char`); - } - ret[i] = code; - } - return ret; -} -/** - * Alias to latin1ToU8Array - */ -// export function bytes(s: string): Uint8Array { -// return latin1ToU8Array(s); -// } -/** - * Alias to u8ArrayToLatin1 - */ -export function str(a) { - return u8ArrayToLatin1(a); -} /** * Concat two Uint8Array * @param array1 * @param array2 * @returns the concatenation of two array */ -export function u8ArrayConcat(array1, array2) { +export function concat(array1, array2) { const mergedArray = new Uint8Array(array1.length + array2.length); mergedArray.set(array1); mergedArray.set(array2, array1.length); @@ -93,7 +53,7 @@ export function serializeValueWithOptions(value, { serializer } = { return serializer(value); } export function serialize(valueToSerialize) { - return latin1ToU8Array(JSON.stringify(valueToSerialize, function (key, value) { + return bytes(JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { value: value.toString(), @@ -112,7 +72,7 @@ export function serialize(valueToSerialize) { })); } export function deserialize(valueToDeserialize) { - return JSON.parse(u8ArrayToLatin1(valueToDeserialize), (_, value) => { + return JSON.parse(str(valueToDeserialize), (_, value) => { if (value !== null && typeof value === "object" && Object.keys(value).length === 2 && @@ -138,3 +98,63 @@ export function validateAccountId(accountId) { accountId.length <= 64 && ACCOUNT_ID_REGEX.test(accountId)); } +/** + * A subset of NodeJS TextEncoder API + */ +export class TextEncoder { + constructor() { } + encode(s) { + return env.utf8_string_to_uint8array(s); + } +} +/** + * A subset of NodeJS TextDecoder API. Only support utf-8 and latin1 encoding. + */ +export class TextDecoder { + constructor(encoding = 'utf-8') { + this.encoding = encoding; + } + decode(a) { + if (this.encoding == 'utf-8') { + return env.uint8array_to_utf8_string(a); + } + else if (this.encoding == 'latin1') { + return env.uint8array_to_latin1_string(a); + } + else { + throw new Error('unsupported encoding: ' + this.encoding); + } + } +} +/** + * Convert a string to Uint8Array, each character must have a char code between 0-255. + * @param s - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export function bytes(s) { + return env.latin1_string_to_uint8array(s); +} +/** + * Convert a Uint8Array to string, each uint8 to the single character of that char code + * @param a - Uint8Array to convert + * @returns result string + */ +export function str(a) { + return env.uint8array_to_latin1_string(a); +} +/** + * Encode the string to Uint8Array with UTF-8 encoding + * @param s - String to encode + * @returns result Uint8Array + */ +export function encode(s) { + return env.utf8_string_to_uint8array(s); +} +/** + * Decode the Uint8Array to string in UTF-8 encoding + * @param a - array to decode + * @returns result string + */ +export function decode(a) { + return env.uint8array_to_utf8_string(a); +} diff --git a/src/api.ts b/src/api.ts index 3dfabfe92..d775473d0 100644 --- a/src/api.ts +++ b/src/api.ts @@ -3,7 +3,7 @@ import { NearAmount, PromiseIndex, Register, - u8ArrayToLatin1, + str, } from "./utils"; import { GasWeight, PromiseResult } from "./types"; @@ -178,7 +178,7 @@ export function log(...params: unknown[]): void { */ export function signerAccountId(): string { env.signer_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** @@ -196,7 +196,7 @@ export function signerAccountPk(): Uint8Array { */ export function predecessorAccountId(): string { env.predecessor_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** @@ -204,7 +204,7 @@ export function predecessorAccountId(): string { */ export function currentAccountId(): string { env.current_account_id(0); - return u8ArrayToLatin1(env.read_register(0)); + return str(env.read_register(0)); } /** @@ -839,29 +839,3 @@ export function altBn128G1Sum(value: Uint8Array): Uint8Array { export function altBn128PairingCheck(value: Uint8Array): boolean { return env.alt_bn128_pairing_check(value) === 1n; } - -export class TextEncoder { - constructor() {} - - encode(s: string): Uint8Array { - return env.utf8_string_to_uint8array(s) - } -} - -export class TextDecoder { - constructor(public encoding: string = 'utf-8') {} - - decode(a: Uint8Array): string { - if (this.encoding == 'utf-8') { - return env.uint8array_to_utf8_string(a) - } else if (this.encoding == 'latin1') { - return env.uint8array_to_latin1_string(a) - } else { - throw new Error('unsupported encoding: ' + this.encoding) - } - } -} - -export function bytes(s: string): Uint8Array { - return env.latin1_string_to_uint8array(s) -} diff --git a/src/collections/lookup-map.ts b/src/collections/lookup-map.ts index 4fe5aa567..5b8217940 100644 --- a/src/collections/lookup-map.ts +++ b/src/collections/lookup-map.ts @@ -3,7 +3,7 @@ import { GetOptions } from "../types/collections"; import { getValueWithOptions, serializeValueWithOptions, - u8ArrayConcat, + concat, } from "../utils"; /** @@ -21,7 +21,7 @@ export class LookupMap { * @param key - The value for which to check the presence. */ containsKey(key: Uint8Array): boolean { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); return near.storageHasKey(storageKey); } @@ -35,7 +35,7 @@ export class LookupMap { key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); const value = near.storageRead(storageKey); return getValueWithOptions(value, options); @@ -51,7 +51,7 @@ export class LookupMap { key: Uint8Array, options?: Omit, "serializer"> ): DataType | null { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; @@ -74,7 +74,7 @@ export class LookupMap { newValue: DataType, options?: GetOptions ): DataType | null { - const storageKey = u8ArrayConcat(this.keyPrefix, key); + const storageKey = concat(this.keyPrefix, key); const storageValue = serializeValueWithOptions(newValue, options); if (!near.storageWrite(storageKey, storageValue)) { diff --git a/src/collections/lookup-set.ts b/src/collections/lookup-set.ts index bad4d075b..26257fcfd 100644 --- a/src/collections/lookup-set.ts +++ b/src/collections/lookup-set.ts @@ -1,6 +1,6 @@ import * as near from "../api"; import { GetOptions } from "../types/collections"; -import { serializeValueWithOptions, u8ArrayConcat } from "../utils"; +import { serializeValueWithOptions, concat } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. @@ -21,7 +21,7 @@ export class LookupSet { key: Uint8Array, options?: Pick, "serializer"> ): boolean { - const storageKey = u8ArrayConcat( + const storageKey = concat( this.keyPrefix, serializeValueWithOptions(key, options) ); @@ -38,7 +38,7 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = u8ArrayConcat( + const storageKey = concat( this.keyPrefix, serializeValueWithOptions(key, options) ); @@ -56,7 +56,7 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = u8ArrayConcat( + const storageKey = concat( this.keyPrefix, serializeValueWithOptions(key, options) ); diff --git a/src/collections/unordered-map.ts b/src/collections/unordered-map.ts index aecfdaf71..f1cc73c25 100644 --- a/src/collections/unordered-map.ts +++ b/src/collections/unordered-map.ts @@ -2,10 +2,10 @@ import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, - latin1ToU8Array, + bytes, Mutable, serializeValueWithOptions, - u8ArrayConcat, + concat, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; @@ -25,10 +25,10 @@ export class UnorderedMap { */ constructor(readonly prefix: Uint8Array) { this.keys = new Vector( - u8ArrayConcat(prefix, latin1ToU8Array("u")) + concat(prefix, bytes("u")) ); // intentional different prefix with old UnorderedMap this.values = new LookupMap( - u8ArrayConcat(prefix, latin1ToU8Array("m")) + concat(prefix, bytes("m")) ); } @@ -210,11 +210,11 @@ export class UnorderedMap { const map = new UnorderedMap(data.prefix) as MutableUnorderedMap; // reconstruct keys Vector - map.keys = new Vector(u8ArrayConcat(data.prefix, latin1ToU8Array("u"))); + map.keys = new Vector(concat(data.prefix, bytes("u"))); map.keys.length = data.keys.length; // reconstruct values LookupMap map.values = new LookupMap( - u8ArrayConcat(data.prefix, latin1ToU8Array("m")) + concat(data.prefix, bytes("m")) ); return map as UnorderedMap; diff --git a/src/collections/unordered-set.ts b/src/collections/unordered-set.ts index 88f71e4c5..f70d2d013 100644 --- a/src/collections/unordered-set.ts +++ b/src/collections/unordered-set.ts @@ -3,8 +3,8 @@ import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, - u8ArrayConcat, - latin1ToU8Array, + concat, + bytes } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { Mutable } from "../utils"; @@ -34,8 +34,8 @@ export class UnorderedSet { * @param prefix - The byte prefix to use when storing elements inside this collection. */ constructor(readonly prefix: Uint8Array) { - this.elementIndexPrefix = u8ArrayConcat(prefix, latin1ToU8Array("i")); - this.elements = new Vector(u8ArrayConcat(prefix, latin1ToU8Array("e"))); + this.elementIndexPrefix = concat(prefix, bytes("i")); + this.elements = new Vector(concat(prefix, bytes("e"))); } /** @@ -62,7 +62,7 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = u8ArrayConcat( + const indexLookup = concat( this.elementIndexPrefix, serializeValueWithOptions(element, options) ); @@ -80,7 +80,7 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = u8ArrayConcat( + const indexLookup = concat( this.elementIndexPrefix, serializeValueWithOptions(element, options) ); @@ -103,7 +103,7 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element: DataType, options?: GetOptions): boolean { - const indexLookup = u8ArrayConcat( + const indexLookup = concat( this.elementIndexPrefix, serializeValueWithOptions(element, options) ); @@ -136,7 +136,7 @@ export class UnorderedSet { // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = u8ArrayConcat( + const lastLookupElement = concat( this.elementIndexPrefix, serializeValueWithOptions(lastElement, options) ); @@ -155,7 +155,7 @@ export class UnorderedSet { */ clear(options?: Pick, "serializer">): void { for (const element of this.elements) { - const indexLookup = u8ArrayConcat( + const indexLookup = concat( this.elementIndexPrefix, serializeValueWithOptions(element, options) ); @@ -231,7 +231,7 @@ export class UnorderedSet { type MutableUnorderedSet = Mutable>; const set = new UnorderedSet(data.prefix) as MutableUnorderedSet; // reconstruct Vector - const elementsPrefix = u8ArrayConcat(data.prefix, latin1ToU8Array("e")); + const elementsPrefix = concat(data.prefix, bytes("e")); set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; diff --git a/src/collections/vector.ts b/src/collections/vector.ts index df19b0ec7..1b1340dd4 100644 --- a/src/collections/vector.ts +++ b/src/collections/vector.ts @@ -5,7 +5,7 @@ import { serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, - u8ArrayConcat, + concat, } from "../utils"; import { GetOptions } from "../types/collections"; @@ -13,7 +13,7 @@ function indexToKey(prefix: Uint8Array, index: number): Uint8Array { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return u8ArrayConcat(prefix, array); + return concat(prefix, array); } /** diff --git a/src/index.ts b/src/index.ts index 47fa702b2..434577a5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ export * as near from "./api"; -export {bytes} from "./api"; export * from "./types"; export * from "./near-bindgen"; export * from "./collections"; diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index 9bb01b3a2..50cf46b13 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -1,9 +1,9 @@ import * as near from "./api"; import { deserialize, - latin1ToU8Array, serialize, - u8ArrayToLatin1, + bytes, + str } from "./utils"; type EmptyParameterObject = Record; @@ -171,24 +171,24 @@ export function NearBindgen({ } static _getState(): unknown | null { - const rawState = near.storageRead(latin1ToU8Array("STATE")); + const rawState = near.storageRead(bytes("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave: unknown): void { near.storageWrite( - latin1ToU8Array("STATE"), + bytes("STATE"), this._serialize(objectToSave) ); } static _getArgs(): unknown { - return JSON.parse(u8ArrayToLatin1(near.input()) || "{}"); + return JSON.parse(str(near.input()) || "{}"); } static _serialize(value: unknown, forReturn = false): Uint8Array { if (forReturn) { - return latin1ToU8Array( + return bytes( JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value ) diff --git a/src/types/public_key.ts b/src/types/public_key.ts index bb627a705..5360b7a6f 100644 --- a/src/types/public_key.ts +++ b/src/types/public_key.ts @@ -1,5 +1,5 @@ import { base58 } from "@scure/base"; -import { u8ArrayConcat } from "../utils"; +import { concat } from "../utils"; export enum CurveType { ED25519 = 0, @@ -121,6 +121,6 @@ export class PublicKey { throw new Base58Error(error.message); } - return new PublicKey(u8ArrayConcat(new Uint8Array([curve]), data)); + return new PublicKey(concat(new Uint8Array([curve]), data)); } } diff --git a/src/utils.ts b/src/utils.ts index 2bb698b2e..4616d8e43 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,14 @@ import { GetOptions } from "./types/collections"; +export interface Env { + uint8array_to_latin1_string(a: Uint8Array): string; + uint8array_to_utf8_string(a: Uint8Array): string; + latin1_string_to_uint8array(s: string): Uint8Array; + utf8_string_to_uint8array(s: string): Uint8Array; +} + +declare const env: Env; + // make PromiseIndex a nominal typing enum PromiseIndexBrand { _ = -1, @@ -30,59 +39,13 @@ export const ERR_INDEX_OUT_OF_BOUNDS = "Index out of bounds"; const ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/; -/** - * Convert a Uint8Array to string, use Latin1 encoding - * @param array - Uint8Array to convert - * @returns result string - */ -export function u8ArrayToLatin1(array: Uint8Array): string { - let ret = ""; - for (const e of array) { - ret += String.fromCharCode(e); - } - return ret; -} - -/** - * Convert a Latin1 string to Uint8Array - * @param latin1 - string that with only Latin1 character to convert - * @returns result Uint8Array - */ -export function latin1ToU8Array(latin1: string): Uint8Array { - const ret = new Uint8Array(latin1.length); - for (let i = 0; i < latin1.length; i++) { - const code = latin1.charCodeAt(i); - if (code > 255) { - throw new Error( - `string at index ${i}: ${latin1[i]} is not a valid latin1 char` - ); - } - ret[i] = code; - } - return ret; -} - -/** - * Alias to latin1ToU8Array - */ -// export function bytes(s: string): Uint8Array { -// return latin1ToU8Array(s); -// } - -/** - * Alias to u8ArrayToLatin1 - */ -export function str(a: Uint8Array): string { - return u8ArrayToLatin1(a) -} - /** * Concat two Uint8Array * @param array1 * @param array2 * @returns the concatenation of two array */ -export function u8ArrayConcat( +export function concat( array1: Uint8Array, array2: Uint8Array ): Uint8Array { @@ -138,7 +101,7 @@ export function serializeValueWithOptions( } export function serialize(valueToSerialize: unknown): Uint8Array { - return latin1ToU8Array( + return bytes( JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { @@ -164,7 +127,7 @@ export function serialize(valueToSerialize: unknown): Uint8Array { } export function deserialize(valueToDeserialize: Uint8Array): unknown { - return JSON.parse(u8ArrayToLatin1(valueToDeserialize), (_, value) => { + return JSON.parse(str(valueToDeserialize), (_, value) => { if ( value !== null && typeof value === "object" && @@ -196,3 +159,67 @@ export function validateAccountId(accountId: string): boolean { ACCOUNT_ID_REGEX.test(accountId) ); } + +/** + * A subset of NodeJS TextEncoder API + */ + export class TextEncoder { + constructor() {} + + encode(s: string): Uint8Array { + return env.utf8_string_to_uint8array(s) + } +} + +/** + * A subset of NodeJS TextDecoder API. Only support utf-8 and latin1 encoding. + */ +export class TextDecoder { + constructor(public encoding: string = 'utf-8') {} + + decode(a: Uint8Array): string { + if (this.encoding == 'utf-8') { + return env.uint8array_to_utf8_string(a) + } else if (this.encoding == 'latin1') { + return env.uint8array_to_latin1_string(a) + } else { + throw new Error('unsupported encoding: ' + this.encoding) + } + } +} + +/** + * Convert a string to Uint8Array, each character must have a char code between 0-255. + * @param s - string that with only Latin1 character to convert + * @returns result Uint8Array + */ +export function bytes(s: string): Uint8Array { + return env.latin1_string_to_uint8array(s) +} + +/** + * Convert a Uint8Array to string, each uint8 to the single character of that char code + * @param a - Uint8Array to convert + * @returns result string + */ +export function str(a: Uint8Array): string { + return env.uint8array_to_latin1_string(a); +} + +/** + * Encode the string to Uint8Array with UTF-8 encoding + * @param s - String to encode + * @returns result Uint8Array + */ +export function encode(s: string): Uint8Array { + return env.utf8_string_to_uint8array(s); +} + +/** + * Decode the Uint8Array to string in UTF-8 encoding + * @param a - array to decode + * @returns result string + */ +export function decode(a: Uint8Array): string { + return env.uint8array_to_utf8_string(a); +} From 46304fc064c7ca300645c64703b5fb9bf9e1a76a Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 2 Dec 2022 22:15:05 +0800 Subject: [PATCH 12/24] fix near bindgen and collections utf 8 char issue --- lib/collections/lookup-map.d.ts | 14 ++-- lib/collections/lookup-map.js | 18 ++--- lib/collections/lookup-set.d.ts | 6 +- lib/collections/lookup-set.js | 14 ++-- lib/collections/unordered-map.d.ts | 20 +++--- lib/collections/unordered-map.js | 22 +++---- lib/collections/unordered-set.d.ts | 6 +- lib/collections/unordered-set.js | 35 +++++----- lib/collections/vector.d.ts | 4 +- lib/collections/vector.js | 17 ++--- lib/near-bindgen.js | 6 +- lib/utils.d.ts | 2 +- lib/utils.js | 7 +- src/collections/lookup-map.ts | 30 ++++----- src/collections/lookup-set.ts | 27 +++----- src/collections/unordered-map.ts | 50 +++++++------- src/collections/unordered-set.ts | 66 ++++++++----------- src/collections/vector.ts | 22 ++++--- src/near-bindgen.ts | 7 +- src/utils.ts | 10 ++- tests/__tests__/test_highlevel_promise.ava.js | 2 + tests/src/highlevel-promise.js | 14 ++-- 22 files changed, 193 insertions(+), 206 deletions(-) diff --git a/lib/collections/lookup-map.d.ts b/lib/collections/lookup-map.d.ts index bf6aa818d..4bd45f5e0 100644 --- a/lib/collections/lookup-map.d.ts +++ b/lib/collections/lookup-map.d.ts @@ -3,31 +3,31 @@ import { GetOptions } from "../types/collections"; * A lookup map that stores data in NEAR storage. */ export declare class LookupMap { - readonly keyPrefix: Uint8Array; + readonly keyPrefix: string; /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(keyPrefix: Uint8Array); + constructor(keyPrefix: string); /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. */ - containsKey(key: Uint8Array): boolean; + containsKey(key: string): boolean; /** * Get the data stored at the provided key. * * @param key - The key at which to look for the data. * @param options - Options for retrieving the data. */ - get(key: Uint8Array, options?: Omit, "serializer">): DataType | null; + get(key: string, options?: Omit, "serializer">): DataType | null; /** * Removes and retrieves the element with the provided key. * * @param key - The key at which to remove data. * @param options - Options for retrieving the data. */ - remove(key: Uint8Array, options?: Omit, "serializer">): DataType | null; + remove(key: string, options?: Omit, "serializer">): DataType | null; /** * Store a new value at the provided key. * @@ -35,14 +35,14 @@ export declare class LookupMap { * @param newValue - The value to store in the collection. * @param options - Options for retrieving and storing the data. */ - set(key: Uint8Array, newValue: DataType, options?: GetOptions): DataType | null; + set(key: string, newValue: DataType, options?: GetOptions): DataType | null; /** * Extends the current collection with the passed in array of key-value pairs. * * @param keyValuePairs - The key-value pairs to extend the collection with. * @param options - Options for storing the data. */ - extend(keyValuePairs: [Uint8Array, DataType][], options?: GetOptions): void; + extend(keyValuePairs: [string, DataType][], options?: GetOptions): void; /** * Serialize the collection. * diff --git a/lib/collections/lookup-map.js b/lib/collections/lookup-map.js index 30f9c00f8..2e0297e9d 100644 --- a/lib/collections/lookup-map.js +++ b/lib/collections/lookup-map.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { getValueWithOptions, serializeValueWithOptions, concat, } from "../utils"; +import { getValueWithOptions, serializeValueWithOptions, encode } from "../utils"; /** * A lookup map that stores data in NEAR storage. */ @@ -16,8 +16,8 @@ export class LookupMap { * @param key - The value for which to check the presence. */ containsKey(key) { - const storageKey = concat(this.keyPrefix, key); - return near.storageHasKey(storageKey); + const storageKey = this.keyPrefix + key; + return near.storageHasKey(encode(storageKey)); } /** * Get the data stored at the provided key. @@ -26,8 +26,8 @@ export class LookupMap { * @param options - Options for retrieving the data. */ get(key, options) { - const storageKey = concat(this.keyPrefix, key); - const value = near.storageRead(storageKey); + const storageKey = this.keyPrefix + key; + const value = near.storageRead(encode(storageKey)); return getValueWithOptions(value, options); } /** @@ -37,8 +37,8 @@ export class LookupMap { * @param options - Options for retrieving the data. */ remove(key, options) { - const storageKey = concat(this.keyPrefix, key); - if (!near.storageRemove(storageKey)) { + const storageKey = this.keyPrefix + key; + if (!near.storageRemove(encode(storageKey))) { return options?.defaultValue ?? null; } const value = near.storageGetEvicted(); @@ -52,9 +52,9 @@ export class LookupMap { * @param options - Options for retrieving and storing the data. */ set(key, newValue, options) { - const storageKey = concat(this.keyPrefix, key); + const storageKey = this.keyPrefix + key; const storageValue = serializeValueWithOptions(newValue, options); - if (!near.storageWrite(storageKey, storageValue)) { + if (!near.storageWrite(encode(storageKey), storageValue)) { return options?.defaultValue ?? null; } const value = near.storageGetEvicted(); diff --git a/lib/collections/lookup-set.d.ts b/lib/collections/lookup-set.d.ts index 58a8c4d70..c8097eab4 100644 --- a/lib/collections/lookup-set.d.ts +++ b/lib/collections/lookup-set.d.ts @@ -3,18 +3,18 @@ import { GetOptions } from "../types/collections"; * A lookup set collection that stores entries in NEAR storage. */ export declare class LookupSet { - readonly keyPrefix: Uint8Array; + readonly keyPrefix: string; /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(keyPrefix: Uint8Array); + constructor(keyPrefix: string); /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. * @param options - Options for storing data. */ - contains(key: Uint8Array, options?: Pick, "serializer">): boolean; + contains(key: DataType, options?: Pick, "serializer">): boolean; /** * Returns true if the element was present in the set. * diff --git a/lib/collections/lookup-set.js b/lib/collections/lookup-set.js index 88d31f7e2..db157b148 100644 --- a/lib/collections/lookup-set.js +++ b/lib/collections/lookup-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { serializeValueWithOptions, concat } from "../utils"; +import { serializeValueWithOptions, encode } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. */ @@ -17,8 +17,8 @@ export class LookupSet { * @param options - Options for storing data. */ contains(key, options) { - const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); - return near.storageHasKey(storageKey); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return near.storageHasKey(encode(storageKey)); } /** * Returns true if the element was present in the set. @@ -27,8 +27,8 @@ export class LookupSet { * @param options - Options for storing data. */ remove(key, options) { - const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); - return near.storageRemove(storageKey); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return near.storageRemove(encode(storageKey)); } /** * If the set did not have this value present, `true` is returned. @@ -38,8 +38,8 @@ export class LookupSet { * @param options - Options for storing the data. */ set(key, options) { - const storageKey = concat(this.keyPrefix, serializeValueWithOptions(key, options)); - return !near.storageWrite(storageKey, new Uint8Array()); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return !near.storageWrite(encode(storageKey), new Uint8Array()); } /** * Extends the current collection with the passed in array of elements. diff --git a/lib/collections/unordered-map.d.ts b/lib/collections/unordered-map.d.ts index 63c8c7da0..d2fd98fb0 100644 --- a/lib/collections/unordered-map.d.ts +++ b/lib/collections/unordered-map.d.ts @@ -1,18 +1,18 @@ import { Vector } from "./vector"; import { LookupMap } from "./lookup-map"; import { GetOptions } from "../types/collections"; -declare type ValueAndIndex = [value: Uint8Array, index: number]; +declare type ValueAndIndex = [value: string, index: number]; /** * An unordered map that stores data in NEAR storage. */ export declare class UnorderedMap { - readonly prefix: Uint8Array; - readonly keys: Vector; + readonly prefix: string; + readonly keys: Vector; readonly values: LookupMap; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(prefix: Uint8Array); + constructor(prefix: string); /** * The number of elements stored in the collection. */ @@ -27,7 +27,7 @@ export declare class UnorderedMap { * @param key - The key at which to look for the data. * @param options - Options for retrieving the data. */ - get(key: Uint8Array, options?: Omit, "serializer">): DataType | null; + get(key: string, options?: Omit, "serializer">): DataType | null; /** * Store a new value at the provided key. * @@ -35,14 +35,14 @@ export declare class UnorderedMap { * @param value - The value to store in the collection. * @param options - Options for retrieving and storing the data. */ - set(key: Uint8Array, value: DataType, options?: GetOptions): DataType | null; + set(key: string, value: DataType, options?: GetOptions): DataType | null; /** * Removes and retrieves the element with the provided key. * * @param key - The key at which to remove data. * @param options - Options for retrieving the data. */ - remove(key: Uint8Array, options?: Omit, "serializer">): DataType | null; + remove(key: string, options?: Omit, "serializer">): DataType | null; /** * Remove all of the elements stored within the collection. */ @@ -59,13 +59,13 @@ export declare class UnorderedMap { * * @param options - Options for retrieving and storing the data. */ - toArray(options?: GetOptions): [Uint8Array, DataType][]; + toArray(options?: GetOptions): [string, DataType][]; /** * Extends the current collection with the passed in array of key-value pairs. * * @param keyValuePairs - The key-value pairs to extend the collection with. */ - extend(keyValuePairs: [Uint8Array, DataType][]): void; + extend(keyValuePairs: [string, DataType][]): void; /** * Serialize the collection. * @@ -92,7 +92,7 @@ declare class UnorderedMapIterator { */ constructor(unorderedMap: UnorderedMap, options?: GetOptions); next(): { - value: [Uint8Array | null, DataType | null]; + value: [string | null, DataType | null]; done: boolean; }; } diff --git a/lib/collections/unordered-map.js b/lib/collections/unordered-map.js index c2c04ef83..02b39cf7c 100644 --- a/lib/collections/unordered-map.js +++ b/lib/collections/unordered-map.js @@ -1,4 +1,4 @@ -import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, bytes, serializeValueWithOptions, concat, } from "../utils"; +import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, serializeValueWithOptions, encode, decode } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; /** @@ -10,8 +10,8 @@ export class UnorderedMap { */ constructor(prefix) { this.prefix = prefix; - this.keys = new Vector(concat(prefix, bytes("u"))); // intentional different prefix with old UnorderedMap - this.values = new LookupMap(concat(prefix, bytes("m"))); + this.keys = new Vector(`${prefix}u`); // intentional different prefix with old UnorderedMap + this.values = new LookupMap(`${prefix}m`); } /** * The number of elements stored in the collection. @@ -37,7 +37,7 @@ export class UnorderedMap { return options?.defaultValue ?? null; } const [value] = valueAndIndex; - return getValueWithOptions(value, options); + return getValueWithOptions(encode(value), options); } /** * Store a new value at the provided key. @@ -52,12 +52,12 @@ export class UnorderedMap { if (valueAndIndex === null) { const newElementIndex = this.length; this.keys.push(key); - this.values.set(key, [serialized, newElementIndex]); + this.values.set(key, [decode(serialized), newElementIndex]); return null; } const [oldValue, oldIndex] = valueAndIndex; - this.values.set(key, [serialized, oldIndex]); - return getValueWithOptions(oldValue, options); + this.values.set(key, [decode(serialized), oldIndex]); + return getValueWithOptions(encode(oldValue), options); } /** * Removes and retrieves the element with the provided key. @@ -80,7 +80,7 @@ export class UnorderedMap { assert(swappedValueAndIndex !== null, ERR_INCONSISTENT_STATE); this.values.set(swappedKey, [swappedValueAndIndex[0], index]); } - return getValueWithOptions(value, options); + return getValueWithOptions(encode(value), options); } /** * Remove all of the elements stored within the collection. @@ -144,10 +144,10 @@ export class UnorderedMap { static reconstruct(data) { const map = new UnorderedMap(data.prefix); // reconstruct keys Vector - map.keys = new Vector(concat(data.prefix, bytes("u"))); + map.keys = new Vector(`${data.prefix}u`); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap(concat(data.prefix, bytes("m"))); + map.values = new LookupMap(`${data.prefix}m`); return map; } } @@ -173,7 +173,7 @@ class UnorderedMapIterator { assert(valueAndIndex !== null, ERR_INCONSISTENT_STATE); return { done: key.done, - value: [key.value, getValueWithOptions(valueAndIndex[0], this.options)], + value: [key.value, getValueWithOptions(encode(valueAndIndex[0]), this.options)], }; } } diff --git a/lib/collections/unordered-set.d.ts b/lib/collections/unordered-set.d.ts index 7f7f9aa88..9b758acae 100644 --- a/lib/collections/unordered-set.d.ts +++ b/lib/collections/unordered-set.d.ts @@ -4,13 +4,13 @@ import { GetOptions } from "../types/collections"; * An unordered set that stores data in NEAR storage. */ export declare class UnorderedSet { - readonly prefix: Uint8Array; - readonly elementIndexPrefix: Uint8Array; + readonly prefix: string; + readonly elementIndexPrefix: string; readonly elements: Vector; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(prefix: Uint8Array); + constructor(prefix: string); /** * The number of elements stored in the collection. */ diff --git a/lib/collections/unordered-set.js b/lib/collections/unordered-set.js index 0b38fe00b..ae47e5d04 100644 --- a/lib/collections/unordered-set.js +++ b/lib/collections/unordered-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, concat, bytes } from "../utils"; +import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, encode } from "../utils"; import { Vector, VectorIterator } from "./vector"; function serializeIndex(index) { const data = new Uint32Array([index]); @@ -19,8 +19,8 @@ export class UnorderedSet { */ constructor(prefix) { this.prefix = prefix; - this.elementIndexPrefix = concat(prefix, bytes("i")); - this.elements = new Vector(concat(prefix, bytes("e"))); + this.elementIndexPrefix = `${prefix}i`; + this.elements = new Vector(`${prefix}e`); } /** * The number of elements stored in the collection. @@ -41,8 +41,8 @@ export class UnorderedSet { * @param options - Options for storing data. */ contains(element, options) { - const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); - return near.storageHasKey(indexLookup); + const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + return near.storageHasKey(encode(indexLookup)); } /** * If the set did not have this value present, `true` is returned. @@ -52,13 +52,13 @@ export class UnorderedSet { * @param options - Options for storing the data. */ set(element, options) { - const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); - if (near.storageRead(indexLookup)) { + const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + if (near.storageRead(encode(indexLookup))) { return false; } const nextIndex = this.length; const nextIndexRaw = serializeIndex(nextIndex); - near.storageWrite(indexLookup, nextIndexRaw); + near.storageWrite(encode(indexLookup), nextIndexRaw); this.elements.push(element, options); return true; } @@ -69,15 +69,15 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element, options) { - const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); - const indexRaw = near.storageRead(indexLookup); + const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexRaw = near.storageRead(encode(indexLookup)); if (!indexRaw) { return false; } // If there is only one element then swap remove simply removes it without // swapping with the last element. if (this.length === 1) { - near.storageRemove(indexLookup); + near.storageRemove(encode(indexLookup)); const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); return true; @@ -86,12 +86,13 @@ export class UnorderedSet { // element. const lastElement = this.elements.get(this.length - 1, options); assert(!!lastElement, ERR_INCONSISTENT_STATE); - near.storageRemove(indexLookup); + near.storageRemove(encode(indexLookup)); // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = concat(this.elementIndexPrefix, serializeValueWithOptions(lastElement, options)); - near.storageWrite(lastLookupElement, indexRaw); + const lastLookupElement = this.elementIndexPrefix + + serializeValueWithOptions(lastElement, options); + near.storageWrite(encode(lastLookupElement), indexRaw); } const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); @@ -102,8 +103,8 @@ export class UnorderedSet { */ clear(options) { for (const element of this.elements) { - const indexLookup = concat(this.elementIndexPrefix, serializeValueWithOptions(element, options)); - near.storageRemove(indexLookup); + const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); + near.storageRemove(encode(indexLookup)); } this.elements.clear(); } @@ -159,7 +160,7 @@ export class UnorderedSet { static reconstruct(data) { const set = new UnorderedSet(data.prefix); // reconstruct Vector - const elementsPrefix = concat(data.prefix, bytes("e")); + const elementsPrefix = data.prefix + "e"; set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; return set; diff --git a/lib/collections/vector.d.ts b/lib/collections/vector.d.ts index a867f4951..5261f78dd 100644 --- a/lib/collections/vector.d.ts +++ b/lib/collections/vector.d.ts @@ -4,13 +4,13 @@ import { GetOptions } from "../types/collections"; * Uses the following map: index -> element */ export declare class Vector { - readonly prefix: Uint8Array; + readonly prefix: string; length: number; /** * @param prefix - The byte prefix to use when storing elements inside this collection. * @param length - The initial length of the collection. By default 0. */ - constructor(prefix: Uint8Array, length?: number); + constructor(prefix: string, length?: number); /** * Checks whether the collection is empty. */ diff --git a/lib/collections/vector.js b/lib/collections/vector.js index c55910bcf..980d84683 100644 --- a/lib/collections/vector.js +++ b/lib/collections/vector.js @@ -1,9 +1,10 @@ import * as near from "../api"; -import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, concat, } from "../utils"; +import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, str, bytes } from "../utils"; function indexToKey(prefix, index) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return concat(prefix, array); + const key = str(array); + return prefix + key; } /** * An iterable implementation of vector that stores its content on the trie. @@ -35,7 +36,7 @@ export class Vector { return options?.defaultValue ?? null; } const storageKey = indexToKey(this.prefix, index); - const value = near.storageRead(storageKey); + const value = near.storageRead(bytes(storageKey)); return getValueWithOptions(value, options); } /** @@ -53,7 +54,7 @@ export class Vector { } const key = indexToKey(this.prefix, index); const last = this.pop(options); - assert(near.storageWrite(key, serializeValueWithOptions(last, options)), ERR_INCONSISTENT_STATE); + assert(near.storageWrite(bytes(key), serializeValueWithOptions(last, options)), ERR_INCONSISTENT_STATE); const value = near.storageGetEvicted(); return getValueWithOptions(value, options); } @@ -66,7 +67,7 @@ export class Vector { push(element, options) { const key = indexToKey(this.prefix, this.length); this.length += 1; - near.storageWrite(key, serializeValueWithOptions(element, options)); + near.storageWrite(bytes(key), serializeValueWithOptions(element, options)); } /** * Removes and retrieves the element with the highest index. @@ -80,7 +81,7 @@ export class Vector { const lastIndex = this.length - 1; const lastKey = indexToKey(this.prefix, lastIndex); this.length -= 1; - assert(near.storageRemove(lastKey), ERR_INCONSISTENT_STATE); + assert(near.storageRemove(bytes(lastKey)), ERR_INCONSISTENT_STATE); const value = near.storageGetEvicted(); return getValueWithOptions(value, options); } @@ -94,7 +95,7 @@ export class Vector { replace(index, element, options) { assert(index < this.length, ERR_INDEX_OUT_OF_BOUNDS); const key = indexToKey(this.prefix, index); - assert(near.storageWrite(key, serializeValueWithOptions(element, options)), ERR_INCONSISTENT_STATE); + assert(near.storageWrite(bytes(key), serializeValueWithOptions(element, options)), ERR_INCONSISTENT_STATE); const value = near.storageGetEvicted(); return getValueWithOptions(value, options); } @@ -140,7 +141,7 @@ export class Vector { clear() { for (let index = 0; index < this.length; index++) { const key = indexToKey(this.prefix, index); - near.storageRemove(key); + near.storageRemove(bytes(key)); } this.length = 0; } diff --git a/lib/near-bindgen.js b/lib/near-bindgen.js index 2eb14c9ae..c20662aa4 100644 --- a/lib/near-bindgen.js +++ b/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize, bytes, str } from "./utils"; +import { deserialize, serialize, bytes, encode, decode, } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * @@ -78,11 +78,11 @@ export function NearBindgen({ requireInit = false, serializer = serialize, deser near.storageWrite(bytes("STATE"), this._serialize(objectToSave)); } static _getArgs() { - return JSON.parse(str(near.input()) || "{}"); + return JSON.parse(decode(near.input()) || "{}"); } static _serialize(value, forReturn = false) { if (forReturn) { - return bytes(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value)); + return encode(JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value)); } return serializer(value); } diff --git a/lib/utils.d.ts b/lib/utils.d.ts index d1eac0470..bb59fd287 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -39,7 +39,7 @@ export declare function assert(expression: unknown, message: string): asserts ex export declare type Mutable = { -readonly [P in keyof T]: T[P]; }; -export declare function getValueWithOptions(value: Uint8Array, options?: Omit, "serializer">): DataType | null; +export declare function getValueWithOptions(value: Uint8Array | null, options?: Omit, "serializer">): DataType | null; export declare function serializeValueWithOptions(value: DataType, { serializer }?: Pick, "serializer">): Uint8Array; export declare function serialize(valueToSerialize: unknown): Uint8Array; export declare function deserialize(valueToDeserialize: Uint8Array): unknown; diff --git a/lib/utils.js b/lib/utils.js index fb7f923a2..61e57c119 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -38,6 +38,9 @@ export function assert(expression, message) { export function getValueWithOptions(value, options = { deserializer: deserialize, }) { + if (value === null) { + return options?.defaultValue ?? null; + } const deserialized = deserialize(value); if (deserialized === undefined || deserialized === null) { return options?.defaultValue ?? null; @@ -53,7 +56,7 @@ export function serializeValueWithOptions(value, { serializer } = { return serializer(value); } export function serialize(valueToSerialize) { - return bytes(JSON.stringify(valueToSerialize, function (key, value) { + return encode(JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { value: value.toString(), @@ -72,7 +75,7 @@ export function serialize(valueToSerialize) { })); } export function deserialize(valueToDeserialize) { - return JSON.parse(str(valueToDeserialize), (_, value) => { + return JSON.parse(decode(valueToDeserialize), (_, value) => { if (value !== null && typeof value === "object" && Object.keys(value).length === 2 && diff --git a/src/collections/lookup-map.ts b/src/collections/lookup-map.ts index 5b8217940..6b468113d 100644 --- a/src/collections/lookup-map.ts +++ b/src/collections/lookup-map.ts @@ -3,7 +3,7 @@ import { GetOptions } from "../types/collections"; import { getValueWithOptions, serializeValueWithOptions, - concat, + encode } from "../utils"; /** @@ -13,16 +13,16 @@ export class LookupMap { /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly keyPrefix: Uint8Array) {} + constructor(readonly keyPrefix: string) {} /** * Checks whether the collection contains the value. * * @param key - The value for which to check the presence. */ - containsKey(key: Uint8Array): boolean { - const storageKey = concat(this.keyPrefix, key); - return near.storageHasKey(storageKey); + containsKey(key: string): boolean { + const storageKey = this.keyPrefix + key; + return near.storageHasKey(encode(storageKey)); } /** @@ -32,11 +32,11 @@ export class LookupMap { * @param options - Options for retrieving the data. */ get( - key: Uint8Array, + key: string, options?: Omit, "serializer"> ): DataType | null { - const storageKey = concat(this.keyPrefix, key); - const value = near.storageRead(storageKey); + const storageKey = this.keyPrefix + key; + const value = near.storageRead(encode(storageKey)); return getValueWithOptions(value, options); } @@ -48,12 +48,12 @@ export class LookupMap { * @param options - Options for retrieving the data. */ remove( - key: Uint8Array, + key: string, options?: Omit, "serializer"> ): DataType | null { - const storageKey = concat(this.keyPrefix, key); + const storageKey = this.keyPrefix + key; - if (!near.storageRemove(storageKey)) { + if (!near.storageRemove(encode(storageKey))) { return options?.defaultValue ?? null; } @@ -70,14 +70,14 @@ export class LookupMap { * @param options - Options for retrieving and storing the data. */ set( - key: Uint8Array, + key: string, newValue: DataType, options?: GetOptions ): DataType | null { - const storageKey = concat(this.keyPrefix, key); + const storageKey = this.keyPrefix + key; const storageValue = serializeValueWithOptions(newValue, options); - if (!near.storageWrite(storageKey, storageValue)) { + if (!near.storageWrite(encode(storageKey), storageValue)) { return options?.defaultValue ?? null; } @@ -93,7 +93,7 @@ export class LookupMap { * @param options - Options for storing the data. */ extend( - keyValuePairs: [Uint8Array, DataType][], + keyValuePairs: [string, DataType][], options?: GetOptions ): void { for (const [key, value] of keyValuePairs) { diff --git a/src/collections/lookup-set.ts b/src/collections/lookup-set.ts index 26257fcfd..b2fbc289b 100644 --- a/src/collections/lookup-set.ts +++ b/src/collections/lookup-set.ts @@ -1,6 +1,6 @@ import * as near from "../api"; import { GetOptions } from "../types/collections"; -import { serializeValueWithOptions, concat } from "../utils"; +import { serializeValueWithOptions, encode } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. @@ -9,7 +9,7 @@ export class LookupSet { /** * @param keyPrefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly keyPrefix: Uint8Array) {} + constructor(readonly keyPrefix: string) {} /** * Checks whether the collection contains the value. @@ -18,14 +18,11 @@ export class LookupSet { * @param options - Options for storing data. */ contains( - key: Uint8Array, + key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = concat( - this.keyPrefix, - serializeValueWithOptions(key, options) - ); - return near.storageHasKey(storageKey); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return near.storageHasKey(encode(storageKey)); } /** @@ -38,11 +35,8 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = concat( - this.keyPrefix, - serializeValueWithOptions(key, options) - ); - return near.storageRemove(storageKey); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return near.storageRemove(encode(storageKey)); } /** @@ -56,11 +50,8 @@ export class LookupSet { key: DataType, options?: Pick, "serializer"> ): boolean { - const storageKey = concat( - this.keyPrefix, - serializeValueWithOptions(key, options) - ); - return !near.storageWrite(storageKey, new Uint8Array()); + const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); + return !near.storageWrite(encode(storageKey), new Uint8Array()); } /** diff --git a/src/collections/unordered-map.ts b/src/collections/unordered-map.ts index f1cc73c25..4451829f7 100644 --- a/src/collections/unordered-map.ts +++ b/src/collections/unordered-map.ts @@ -2,34 +2,30 @@ import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, - bytes, Mutable, serializeValueWithOptions, - concat, + encode, + decode } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; import { GetOptions } from "../types/collections"; -type ValueAndIndex = [value: Uint8Array, index: number]; +type ValueAndIndex = [value: string, index: number]; /** * An unordered map that stores data in NEAR storage. */ export class UnorderedMap { - readonly keys: Vector; + readonly keys: Vector; readonly values: LookupMap; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly prefix: Uint8Array) { - this.keys = new Vector( - concat(prefix, bytes("u")) - ); // intentional different prefix with old UnorderedMap - this.values = new LookupMap( - concat(prefix, bytes("m")) - ); + constructor(readonly prefix: string) { + this.keys = new Vector(`${prefix}u`); // intentional different prefix with old UnorderedMap + this.values = new LookupMap(`${prefix}m`); } /** @@ -53,7 +49,7 @@ export class UnorderedMap { * @param options - Options for retrieving the data. */ get( - key: Uint8Array, + key: string, options?: Omit, "serializer"> ): DataType | null { const valueAndIndex = this.values.get(key); @@ -64,7 +60,7 @@ export class UnorderedMap { const [value] = valueAndIndex; - return getValueWithOptions(value, options); + return getValueWithOptions(encode(value), options); } /** @@ -75,7 +71,7 @@ export class UnorderedMap { * @param options - Options for retrieving and storing the data. */ set( - key: Uint8Array, + key: string, value: DataType, options?: GetOptions ): DataType | null { @@ -86,15 +82,15 @@ export class UnorderedMap { const newElementIndex = this.length; this.keys.push(key); - this.values.set(key, [serialized, newElementIndex]); + this.values.set(key, [decode(serialized), newElementIndex]); return null; } const [oldValue, oldIndex] = valueAndIndex; - this.values.set(key, [serialized, oldIndex]); + this.values.set(key, [decode(serialized), oldIndex]); - return getValueWithOptions(oldValue, options); + return getValueWithOptions(encode(oldValue), options); } /** @@ -104,7 +100,7 @@ export class UnorderedMap { * @param options - Options for retrieving the data. */ remove( - key: Uint8Array, + key: string, options?: Omit, "serializer"> ): DataType | null { const oldValueAndIndex = this.values.remove(key); @@ -128,7 +124,7 @@ export class UnorderedMap { this.values.set(swappedKey, [swappedValueAndIndex[0], index]); } - return getValueWithOptions(value, options); + return getValueWithOptions(encode(value), options); } /** @@ -165,7 +161,7 @@ export class UnorderedMap { * * @param options - Options for retrieving and storing the data. */ - toArray(options?: GetOptions): [Uint8Array, DataType][] { + toArray(options?: GetOptions): [string, DataType][] { const array = []; const iterator = options ? this.createIteratorWithOptions(options) : this; @@ -182,7 +178,7 @@ export class UnorderedMap { * * @param keyValuePairs - The key-value pairs to extend the collection with. */ - extend(keyValuePairs: [Uint8Array, DataType][]) { + extend(keyValuePairs: [string, DataType][]) { for (const [key, value] of keyValuePairs) { this.set(key, value); } @@ -210,12 +206,10 @@ export class UnorderedMap { const map = new UnorderedMap(data.prefix) as MutableUnorderedMap; // reconstruct keys Vector - map.keys = new Vector(concat(data.prefix, bytes("u"))); + map.keys = new Vector(`${data.prefix}u`); map.keys.length = data.keys.length; // reconstruct values LookupMap - map.values = new LookupMap( - concat(data.prefix, bytes("m")) - ); + map.values = new LookupMap(`${data.prefix}m`); return map as UnorderedMap; } @@ -225,7 +219,7 @@ export class UnorderedMap { * An iterator for the UnorderedMap collection. */ class UnorderedMapIterator { - private keys: VectorIterator; + private keys: VectorIterator; private map: LookupMap; /** @@ -240,7 +234,7 @@ class UnorderedMapIterator { this.map = unorderedMap.values; } - next(): { value: [Uint8Array | null, DataType | null]; done: boolean } { + next(): { value: [string | null, DataType | null]; done: boolean } { const key = this.keys.next(); if (key.done) { @@ -253,7 +247,7 @@ class UnorderedMapIterator { return { done: key.done, - value: [key.value, getValueWithOptions(valueAndIndex[0], this.options)], + value: [key.value, getValueWithOptions(encode(valueAndIndex[0]), this.options)], }; } } diff --git a/src/collections/unordered-set.ts b/src/collections/unordered-set.ts index f70d2d013..891bcdf9d 100644 --- a/src/collections/unordered-set.ts +++ b/src/collections/unordered-set.ts @@ -3,8 +3,7 @@ import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, - concat, - bytes + encode } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { Mutable } from "../utils"; @@ -14,7 +13,7 @@ function serializeIndex(index: number) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return array; + return array } function deserializeIndex(rawIndex: Uint8Array): number { @@ -27,15 +26,15 @@ function deserializeIndex(rawIndex: Uint8Array): number { * An unordered set that stores data in NEAR storage. */ export class UnorderedSet { - readonly elementIndexPrefix: Uint8Array; + readonly elementIndexPrefix: string; readonly elements: Vector; /** * @param prefix - The byte prefix to use when storing elements inside this collection. */ - constructor(readonly prefix: Uint8Array) { - this.elementIndexPrefix = concat(prefix, bytes("i")); - this.elements = new Vector(concat(prefix, bytes("e"))); + constructor(readonly prefix: string) { + this.elementIndexPrefix = `${prefix}i`; + this.elements = new Vector(`${prefix}e`); } /** @@ -62,11 +61,9 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = concat( - this.elementIndexPrefix, - serializeValueWithOptions(element, options) - ); - return near.storageHasKey(indexLookup); + const indexLookup = + this.elementIndexPrefix + serializeValueWithOptions(element, options); + return near.storageHasKey(encode(indexLookup)); } /** @@ -80,17 +77,16 @@ export class UnorderedSet { element: DataType, options?: Pick, "serializer"> ): boolean { - const indexLookup = concat( - this.elementIndexPrefix, - serializeValueWithOptions(element, options) - ); - if (near.storageRead(indexLookup)) { + const indexLookup = + this.elementIndexPrefix + serializeValueWithOptions(element, options); + + if (near.storageRead(encode(indexLookup))) { return false; } const nextIndex = this.length; const nextIndexRaw = serializeIndex(nextIndex); - near.storageWrite(indexLookup, nextIndexRaw); + near.storageWrite(encode(indexLookup), nextIndexRaw); this.elements.push(element, options); return true; @@ -103,12 +99,9 @@ export class UnorderedSet { * @param options - Options for retrieving and storing data. */ remove(element: DataType, options?: GetOptions): boolean { - const indexLookup = concat( - this.elementIndexPrefix, - serializeValueWithOptions(element, options) - ); - - const indexRaw = near.storageRead(indexLookup); + const indexLookup = + this.elementIndexPrefix + serializeValueWithOptions(element, options); + const indexRaw = near.storageRead(encode(indexLookup)); if (!indexRaw) { return false; @@ -117,7 +110,7 @@ export class UnorderedSet { // If there is only one element then swap remove simply removes it without // swapping with the last element. if (this.length === 1) { - near.storageRemove(indexLookup); + near.storageRemove(encode(indexLookup)); const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); @@ -131,17 +124,15 @@ export class UnorderedSet { assert(!!lastElement, ERR_INCONSISTENT_STATE); - near.storageRemove(indexLookup); + near.storageRemove(encode(indexLookup)); // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { - const lastLookupElement = concat( - this.elementIndexPrefix, - serializeValueWithOptions(lastElement, options) - ); - - near.storageWrite(lastLookupElement, indexRaw); + const lastLookupElement = + this.elementIndexPrefix + + serializeValueWithOptions(lastElement, options); + near.storageWrite(encode(lastLookupElement), indexRaw); } const index = deserializeIndex(indexRaw); @@ -155,11 +146,9 @@ export class UnorderedSet { */ clear(options?: Pick, "serializer">): void { for (const element of this.elements) { - const indexLookup = concat( - this.elementIndexPrefix, - serializeValueWithOptions(element, options) - ); - near.storageRemove(indexLookup); + const indexLookup = + this.elementIndexPrefix + serializeValueWithOptions(element, options); + near.storageRemove(encode(indexLookup)); } this.elements.clear(); @@ -231,8 +220,7 @@ export class UnorderedSet { type MutableUnorderedSet = Mutable>; const set = new UnorderedSet(data.prefix) as MutableUnorderedSet; // reconstruct Vector - const elementsPrefix = concat(data.prefix, bytes("e")); - + const elementsPrefix = data.prefix + "e"; set.elements = new Vector(elementsPrefix); set.elements.length = data.elements.length; diff --git a/src/collections/vector.ts b/src/collections/vector.ts index 1b1340dd4..5db020234 100644 --- a/src/collections/vector.ts +++ b/src/collections/vector.ts @@ -5,15 +5,17 @@ import { serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, - concat, + str, + bytes } from "../utils"; import { GetOptions } from "../types/collections"; -function indexToKey(prefix: Uint8Array, index: number): Uint8Array { +function indexToKey(prefix: string, index: number): string { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); + const key = str(array); - return concat(prefix, array); + return prefix + key; } /** @@ -25,7 +27,7 @@ export class Vector { * @param prefix - The byte prefix to use when storing elements inside this collection. * @param length - The initial length of the collection. By default 0. */ - constructor(readonly prefix: Uint8Array, public length = 0) {} + constructor(readonly prefix: string, public length = 0) {} /** * Checks whether the collection is empty. @@ -49,7 +51,7 @@ export class Vector { } const storageKey = indexToKey(this.prefix, index); - const value = near.storageRead(storageKey); + const value = near.storageRead(bytes(storageKey)); return getValueWithOptions(value, options); } @@ -73,7 +75,7 @@ export class Vector { const last = this.pop(options); assert( - near.storageWrite(key, serializeValueWithOptions(last, options)), + near.storageWrite(bytes(key), serializeValueWithOptions(last, options)), ERR_INCONSISTENT_STATE ); @@ -95,7 +97,7 @@ export class Vector { const key = indexToKey(this.prefix, this.length); this.length += 1; - near.storageWrite(key, serializeValueWithOptions(element, options)); + near.storageWrite(bytes(key), serializeValueWithOptions(element, options)); } /** @@ -112,7 +114,7 @@ export class Vector { const lastKey = indexToKey(this.prefix, lastIndex); this.length -= 1; - assert(near.storageRemove(lastKey), ERR_INCONSISTENT_STATE); + assert(near.storageRemove(bytes(lastKey)), ERR_INCONSISTENT_STATE); const value = near.storageGetEvicted(); @@ -135,7 +137,7 @@ export class Vector { const key = indexToKey(this.prefix, index); assert( - near.storageWrite(key, serializeValueWithOptions(element, options)), + near.storageWrite(bytes(key), serializeValueWithOptions(element, options)), ERR_INCONSISTENT_STATE ); @@ -195,7 +197,7 @@ export class Vector { clear(): void { for (let index = 0; index < this.length; index++) { const key = indexToKey(this.prefix, index); - near.storageRemove(key); + near.storageRemove(bytes(key)); } this.length = 0; diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index 50cf46b13..5519133e8 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -3,7 +3,8 @@ import { deserialize, serialize, bytes, - str + encode, + decode, } from "./utils"; type EmptyParameterObject = Record; @@ -183,12 +184,12 @@ export function NearBindgen({ } static _getArgs(): unknown { - return JSON.parse(str(near.input()) || "{}"); + return JSON.parse(decode(near.input()) || "{}"); } static _serialize(value: unknown, forReturn = false): Uint8Array { if (forReturn) { - return bytes( + return encode( JSON.stringify(value, (_, value) => typeof value === "bigint" ? `${value}` : value ) diff --git a/src/utils.ts b/src/utils.ts index 4616d8e43..b44d29039 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -73,11 +73,15 @@ export function assert( export type Mutable = { -readonly [P in keyof T]: T[P] }; export function getValueWithOptions( - value: Uint8Array, + value: Uint8Array | null, options: Omit, "serializer"> = { deserializer: deserialize, } ): DataType | null { + if (value === null) { + return options?.defaultValue ?? null; + } + const deserialized = deserialize(value); if (deserialized === undefined || deserialized === null) { @@ -101,7 +105,7 @@ export function serializeValueWithOptions( } export function serialize(valueToSerialize: unknown): Uint8Array { - return bytes( + return encode( JSON.stringify(valueToSerialize, function (key, value) { if (typeof value === "bigint") { return { @@ -127,7 +131,7 @@ export function serialize(valueToSerialize: unknown): Uint8Array { } export function deserialize(valueToDeserialize: Uint8Array): unknown { - return JSON.parse(str(valueToDeserialize), (_, value) => { + return JSON.parse(decode(valueToDeserialize), (_, value) => { if ( value !== null && typeof value === "object" && diff --git a/tests/__tests__/test_highlevel_promise.ava.js b/tests/__tests__/test_highlevel_promise.ava.js index f33abc988..ed1e64470 100644 --- a/tests/__tests__/test_highlevel_promise.ava.js +++ b/tests/__tests__/test_highlevel_promise.ava.js @@ -168,6 +168,8 @@ test("cross contract call success then call a panic method", async (t) => { } ); // the last promise fail, cause the transaction fail + console.log( + r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError) t.assert( r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.includes( "Smart contract panicked: it just panic" diff --git a/tests/src/highlevel-promise.js b/tests/src/highlevel-promise.js index 0c5b57a8f..ce3350811 100644 --- a/tests/src/highlevel-promise.js +++ b/tests/src/highlevel-promise.js @@ -1,4 +1,4 @@ -import { NearBindgen, call, NearPromise, near, bytes } from "near-sdk-js"; +import { NearBindgen, call, NearPromise, near, bytes, str } from "near-sdk-js"; import { PublicKey } from "near-sdk-js"; function callingData() { @@ -6,7 +6,7 @@ function callingData() { currentAccountId: near.currentAccountId(), signerAccountId: near.signerAccountId(), predecessorAccountId: near.predecessorAccountId(), - input: near.input(), + input: str(near.input()), }; } @@ -120,7 +120,7 @@ export class HighlevelPromiseContract { return { ...callingData(), promiseResults: arrayN(near.promiseResultsCount()).map((i) => - near.promiseResult(i) + str(near.promiseResult(i)) ), callbackArg1, }; @@ -129,9 +129,9 @@ export class HighlevelPromiseContract { @call({}) cross_contract_callback_write_state() { // Attempt to write something in state. If this one is successfully executed and not revoked, these should be in state - near.storageWrite("aaa", "bbb"); - near.storageWrite("ccc", "ddd"); - near.storageWrite("eee", "fff"); + near.storageWrite(bytes("aaa"), bytes("bbb")); + near.storageWrite(bytes("ccc"), bytes("ddd")); + near.storageWrite(bytes("eee"), bytes("fff")); } @call({}) @@ -213,7 +213,7 @@ export class HighlevelPromiseContract { 2 * Math.pow(10, 13) ) ); - near.storageWrite("aaa", "bbb"); + near.storageWrite(bytes("aaa"), bytes("bbb")); return promise; } From 18f3b61dbcd7ed1350274dc0f9d71fab33f2500c Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 5 Dec 2022 15:42:04 +0800 Subject: [PATCH 13/24] fix bytes tests --- tests/__tests__/bytes.ava.js | 27 +++++++++------------------ tests/src/bytes.js | 15 +++++++++------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/tests/__tests__/bytes.ava.js b/tests/__tests__/bytes.ava.js index be711b714..7ff71e84d 100644 --- a/tests/__tests__/bytes.ava.js +++ b/tests/__tests__/bytes.ava.js @@ -43,9 +43,9 @@ test("Log unexpected types not logging", async (t) => { const { ali, bytesContract } = t.context.accounts; let r = await ali.callRaw(bytesContract, "log_unexpected_input_tests", ""); - // logUtf8 and logUtf16 only works with bytes, trying to log it with string is unexpected and behavior is undefined - // in this specific case, it logs nothing - t.deepEqual(r.result.receipts_outcome[0].outcome.logs, ["", ""]); + // logUtf8 and logUtf16 only works with bytes, trying to log it with string is error + t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint8Array for message')) + t.deepEqual(r.result.receipts_outcome[0].outcome.logs, []); }); test("Log invalid utf-8 sequence panic", async (t) => { @@ -108,24 +108,15 @@ test("storage write bytes tests", async (t) => { ); }); -test("storage write unexpected types tests", async (t) => { +test("storage write utf8 tests", async (t) => { const { ali, bytesContract } = t.context.accounts; - await ali.call(bytesContract, "storage_write_unexpected_input", ""); - let stateMap = new Map(); - // viewState doesn't work, because it tries to convert key to utf-8 string, which is not - let state = await bytesContract.viewStateRaw(); - for (let { key, value } of state) { - stateMap.set(key, value); - } - - t.deepEqual( - stateMap.get(encodeStateKey("123")), - Buffer.from("456").toString("base64") + await ali.call(bytesContract, "storage_write_utf8", ""); + let r = await bytesContract.viewRaw( + "storage_read_utf8", + "" ); - // pass in utf-8 string instead of bytes, key and value become empty - t.deepEqual(stateMap.get(encodeStateKey([0xe6, 0xb0, 0xb4])), undefined); - t.deepEqual(stateMap.get(encodeStateKey([])), ""); + t.deepEqual(r.result, [...Buffer.from('😂', 'utf-8')]); }); test("Storage read bytes tests", async (t) => { diff --git a/tests/src/bytes.js b/tests/src/bytes.js index dcfe2389c..b3c1821b8 100644 --- a/tests/src/bytes.js +++ b/tests/src/bytes.js @@ -1,4 +1,4 @@ -import { near, bytes } from "near-sdk-js"; +import { near, bytes, encode } from "near-sdk-js"; export function log_expected_input_tests() { // log ascii string @@ -8,9 +8,9 @@ export function log_expected_input_tests() { // log number near.log(333); // log aribrary byte sequence - near.log(bytes("\x00\x01\xff")); + near.log("\x00\x01\xff"); // log valid utf8 seqence - near.log(bytes("\xe6\xb0\xb4")); + near.log("\xe6\xb0\xb4"); // log valid utf8 sequence near.logUtf8(bytes("\xe6\xb0\xb4")); @@ -39,9 +39,12 @@ export function storage_write_bytes() { near.storageWrite(bytes("\xe6\xb0\xb4"), bytes("\x00ab")); } -export function storage_write_unexpected_input() { - near.storageWrite("水", "水"); - near.storageWrite(123, 456); +export function storage_write_utf8() { + near.storageWrite(encode("水"), encode("😂")); +} + +export function storage_read_utf8() { + near.valueReturn(near.storageRead(encode("水"))) } export function storage_read_ascii_bytes() { From eec8cb49a96d9ce23a650662229448df49ce3fb6 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 5 Dec 2022 15:47:45 +0800 Subject: [PATCH 14/24] fix public key tests --- tests/src/public-key.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/src/public-key.js b/tests/src/public-key.js index 0f47bde54..27bb3700c 100644 --- a/tests/src/public-key.js +++ b/tests/src/public-key.js @@ -1,4 +1,4 @@ -import { near, bytes } from "near-sdk-js"; +import { near } from "near-sdk-js"; import { CurveType, PublicKey } from "near-sdk-js"; import { assert } from "near-sdk-js"; @@ -16,7 +16,6 @@ export function test_add_signer_key() { export function test_add_ed25519_key_bytes() { let pk = new PublicKey( - bytes( new Uint8Array([ // CurveType.ED25519 = 0 0, @@ -24,7 +23,6 @@ export function test_add_ed25519_key_bytes() { 186, 44, 216, 49, 157, 48, 151, 47, 23, 244, 137, 69, 78, 150, 54, 42, 30, 248, 110, 26, 205, 18, 137, 154, 10, 208, 26, 183, 65, 166, 223, 18, ]) - ) ); runtime_validate_public_key("a", pk.data); } @@ -37,7 +35,6 @@ export function test_add_ed25519_key_string() { export function test_add_secp256k1_key_bytes() { let pk = new PublicKey( - bytes( new Uint8Array([ // CurveType.SECP256K1 = 1 1, @@ -48,7 +45,6 @@ export function test_add_secp256k1_key_bytes() { 193, 71, 193, 233, 163, 140, 228, 40, 135, 142, 125, 70, 225, 251, 113, 74, 153, ]) - ) ); runtime_validate_public_key("c", pk.data); } @@ -63,7 +59,7 @@ export function test_add_secp256k1_key_string() { export function add_invalid_public_key() { runtime_validate_public_key( "e", - bytes(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])) + new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) ); } @@ -74,11 +70,11 @@ export function curve_type() { } export function create_invalid_curve_type() { - new PublicKey(bytes(new Uint8Array([2, 1]))); + new PublicKey(new Uint8Array([2, 1])); } export function create_invalid_length() { - new PublicKey(bytes(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))); + new PublicKey(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); } export function create_from_invalid_base58() { From 28265819b07045484eef26981e6f95bf6a14dd35 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 6 Dec 2022 16:51:17 +0800 Subject: [PATCH 15/24] add all test cases of string<>uint8array conversion --- tests/__tests__/bytes.ava.js | 28 ++++++++++++-- tests/__tests__/lookup-map.ava.js | 19 +++++++++ tests/package.json | 3 -- tests/src/bytes.js | 64 ++++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 7 deletions(-) diff --git a/tests/__tests__/bytes.ava.js b/tests/__tests__/bytes.ava.js index 7ff71e84d..af4b4b152 100644 --- a/tests/__tests__/bytes.ava.js +++ b/tests/__tests__/bytes.ava.js @@ -12,10 +12,11 @@ test.beforeEach(async (t) => { const bytesContract = await root.devDeploy("build/bytes.wasm"); // Test users const ali = await root.createSubAccount("ali"); + const bob = await root.createSubAccount("bob"); // Save state for test runs t.context.worker = worker; - t.context.accounts = { root, bytesContract, ali }; + t.context.accounts = { root, bytesContract, ali, bob }; }); test.afterEach.always(async (t) => { @@ -83,7 +84,7 @@ function encodeStateKey(k) { return Buffer.from(k).toString("base64"); } -test("storage write bytes tests", async (t) => { +test("storage write bytes tests. Any latin1 string: ascii, valid or invalid utf-8 sequence can be convert to Uint8Array correctly", async (t) => { const { ali, bytesContract } = t.context.accounts; await ali.call(bytesContract, "storage_write_bytes", ""); @@ -108,7 +109,7 @@ test("storage write bytes tests", async (t) => { ); }); -test("storage write utf8 tests", async (t) => { +test("storage write utf8, utf8 string convert to Uint8Array tests", async (t) => { const { ali, bytesContract } = t.context.accounts; await ali.call(bytesContract, "storage_write_utf8", ""); @@ -198,3 +199,24 @@ test("panic tests", async (t) => { "String encoding is bad UTF-8 sequence." ); }); + +test("utf8 string can be convert to Uint8Array correctly", async (t) => { + const { bob, bytesContract } = t.context.accounts; + + let res = await bob.callRaw(bytesContract, "utf8_string_to_uint8array_tests", ""); + t.is(res.result.status.SuccessValue, '') +}) + +test("valid utf8 sequence can be convert to string correctly", async (t) => { + const { bob, bytesContract } = t.context.accounts; + + let res = await bob.callRaw(bytesContract, "uint8array_to_utf8_string_tests", ""); + t.is(res.result.status.SuccessValue, '') +}) + +test("latin1 sequence can be convert to string correctly", async (t) => { + const { bob, bytesContract } = t.context.accounts; + + let res = await bob.callRaw(bytesContract, "uint8array_to_latin1_string_tests", ""); + t.is(res.result.status.SuccessValue, '') +}) diff --git a/tests/__tests__/lookup-map.ava.js b/tests/__tests__/lookup-map.ava.js index 824f674b8..2e26a9abf 100644 --- a/tests/__tests__/lookup-map.ava.js +++ b/tests/__tests__/lookup-map.ava.js @@ -92,3 +92,22 @@ test("LookupMap allows you to use the same key for the second time", async (t) = t.is(await lookupMapContract.view("get", { key: "hello" }), "world"); }); + +test.only("UTF-8 in arguments, store in collections & state, return in returns", async (t) => { + const {ali, lookupMapContract} = t.context.accounts; + + let data = { + "utf8emoji": "😂", + "utf8char": "水", + // this is the byte sequence of above utf8 char, it will be escaped in js contract + // so it won't be mis-recorgnized as above utf8 char. + "utf8char_charcode_seq": "\xe6\xb0\xb4", + // this and above shows arbitrary binary data can be put in arguments, state and return + // default serialization and deserialization works + "latin1_charcode_seq": "\xc2\x00\x01\xff" + } + let res = await ali.callRaw(lookupMapContract, "set", {key: "utf8test", value: data}) + t.is(res.result.status.SuccessValue, '') + + t.deepEqual(await lookupMapContract.view("get", { key: "utf8test" }), data); +}) \ No newline at end of file diff --git a/tests/package.json b/tests/package.json index b08807d21..283f549ef 100644 --- a/tests/package.json +++ b/tests/package.json @@ -56,9 +56,6 @@ }, "author": "Near Inc ", "license": "Apache-2.0", - "dependencies": { - "near-sdk-js": "file:../" - }, "devDependencies": { "ava": "^4.2.0", "near-workspaces": "3.2.1", diff --git a/tests/src/bytes.js b/tests/src/bytes.js index b3c1821b8..7f28fb01a 100644 --- a/tests/src/bytes.js +++ b/tests/src/bytes.js @@ -1,4 +1,4 @@ -import { near, bytes, encode } from "near-sdk-js"; +import { near, bytes, str, encode, decode, assert } from "near-sdk-js"; export function log_expected_input_tests() { // log ascii string @@ -90,3 +90,65 @@ export function panicUtf8_valid_utf8_sequence() { export function panicUtf8_invalid_utf8_sequence() { near.panicUtf8(bytes("\x00\x01\xff")); } + +const areEqual = (first, second) => + first.length === second.length && first.every((value, index) => value === second[index]); + +export function utf8_string_to_uint8array_tests() { + let utf8chars = '水😂' + let withUtf8CharCodeSeq = '\xe6\xb0\xb4' + let withArbitraryLatinSeq = '\x00\x01\xff' + + assert(areEqual(encode(utf8chars), new Uint8Array([ + 230, 176, 180, + 240, 159, 152, + 130 + ]))) + assert(areEqual(encode(withUtf8CharCodeSeq), new Uint8Array( + [ 195, 166, 194, 176, 194, 180 ] + ))) + assert(areEqual(encode(withArbitraryLatinSeq), new Uint8Array([ 0, 1, 195, 191 ]))) + + assert(decode(encode(utf8chars)) == utf8chars) + assert(decode(encode(withUtf8CharCodeSeq)) == withUtf8CharCodeSeq) + assert(decode(encode(withArbitraryLatinSeq)) == withArbitraryLatinSeq) +} + +export function uint8array_to_utf8_string_tests() { + let validUtf8SeqArray = new Uint8Array([ + 230, 176, 180, + 240, 159, 152, + 130 + ]) + let escapedUtf8SeqArray = new Uint8Array( + [ 195, 166, 194, 176, 194, 180 ] + ) + let invalidUtf8Seq = new Uint8Array([ 0, 1, 255 ]) + + assert(decode(validUtf8SeqArray) == '水😂') + assert(decode(escapedUtf8SeqArray) == '\xe6\xb0\xb4') + // same behavior as nodejs + assert(decode(invalidUtf8Seq) == '\x00\x01\ufffd') + + assert(areEqual(encode(decode(validUtf8SeqArray)), validUtf8SeqArray)) + assert(areEqual(encode(decode(escapedUtf8SeqArray)), escapedUtf8SeqArray)) + // same behavior as nodejs + assert(areEqual(encode(decode(invalidUtf8Seq)), new Uint8Array([0,1,239,191,189]))) +} + +export function uint8array_to_latin1_string_tests() { + let happensToBeUtf8Seq = new Uint8Array([ + 230, 176, 180, + ]) + let validLatin1InvalidUtf8 = new Uint8Array([ 0, 1, 255 ]) + let ascii = new Uint8Array([65, 66, 67]) + + assert(str(happensToBeUtf8Seq) == '\xe6\xb0\xb4') + assert(str(validLatin1InvalidUtf8) == '\x00\x01\xff') + assert(str(ascii) == '\x41\x42\x43') + + assert(areEqual(bytes(str(happensToBeUtf8Seq)), happensToBeUtf8Seq)) + assert(areEqual(bytes(str(validLatin1InvalidUtf8)), validLatin1InvalidUtf8)) + assert(areEqual(bytes(str(ascii)), ascii)) + +} From f6b837ce2a8088c6e729eeeda3b7b7baaddd77ee Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 6 Dec 2022 16:54:39 +0800 Subject: [PATCH 16/24] lint format --- lib/api.js | 2 +- lib/build-tools/include-bytes.js | 2 +- lib/collections/lookup-map.js | 2 +- lib/collections/unordered-map.js | 7 +- lib/collections/unordered-set.js | 2 +- lib/collections/vector.js | 2 +- lib/near-bindgen.js | 2 +- lib/utils.d.ts | 1 - lib/utils.js | 9 +- src/api.ts | 10 +- src/build-tools/include-bytes.ts | 10 +- src/collections/lookup-map.ts | 2 +- src/collections/unordered-map.ts | 7 +- src/collections/unordered-set.ts | 4 +- src/collections/vector.ts | 7 +- src/near-bindgen.ts | 13 +-- src/utils.ts | 33 +++---- tests/__tests__/bytes.ava.js | 43 +++++--- tests/__tests__/lookup-map.ava.js | 21 ++-- tests/__tests__/test_highlevel_promise.ava.js | 3 +- tests/__tests__/test_promise_api.ava.js | 2 +- tests/src/bytes.js | 97 ++++++++++--------- tests/src/public-key.js | 33 +++---- 23 files changed, 164 insertions(+), 150 deletions(-) diff --git a/lib/api.js b/lib/api.js index 2a5ea7194..5ac9b265d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,4 +1,4 @@ -import { assert, str, } from "./utils"; +import { assert, str } from "./utils"; import { PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; const EVICTED_REGISTER = U64_MAX - 1n; diff --git a/lib/build-tools/include-bytes.js b/lib/build-tools/include-bytes.js index c7b04e31c..f26e110e4 100644 --- a/lib/build-tools/include-bytes.js +++ b/lib/build-tools/include-bytes.js @@ -35,7 +35,7 @@ export default function () { const fileRelPath = firstArg.value; // Get literal string value const filePath = join(root, fileRelPath); const fileSrc = readFileSync(filePath, { encoding }).toString(); - path.replaceWith(t.callExpression(t.memberExpression(t.identifier('env'), t.identifier('latin1_string_to_uint8array')), [t.stringLiteral(fileSrc)])); + path.replaceWith(t.callExpression(t.memberExpression(t.identifier("env"), t.identifier("latin1_string_to_uint8array")), [t.stringLiteral(fileSrc)])); } }, }, diff --git a/lib/collections/lookup-map.js b/lib/collections/lookup-map.js index 2e0297e9d..e96bd69da 100644 --- a/lib/collections/lookup-map.js +++ b/lib/collections/lookup-map.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { getValueWithOptions, serializeValueWithOptions, encode } from "../utils"; +import { getValueWithOptions, serializeValueWithOptions, encode, } from "../utils"; /** * A lookup map that stores data in NEAR storage. */ diff --git a/lib/collections/unordered-map.js b/lib/collections/unordered-map.js index 02b39cf7c..91f6c74db 100644 --- a/lib/collections/unordered-map.js +++ b/lib/collections/unordered-map.js @@ -1,4 +1,4 @@ -import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, serializeValueWithOptions, encode, decode } from "../utils"; +import { assert, ERR_INCONSISTENT_STATE, getValueWithOptions, serializeValueWithOptions, encode, decode, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; /** @@ -173,7 +173,10 @@ class UnorderedMapIterator { assert(valueAndIndex !== null, ERR_INCONSISTENT_STATE); return { done: key.done, - value: [key.value, getValueWithOptions(encode(valueAndIndex[0]), this.options)], + value: [ + key.value, + getValueWithOptions(encode(valueAndIndex[0]), this.options), + ], }; } } diff --git a/lib/collections/unordered-set.js b/lib/collections/unordered-set.js index ae47e5d04..1fce988a1 100644 --- a/lib/collections/unordered-set.js +++ b/lib/collections/unordered-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, encode } from "../utils"; +import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, encode, } from "../utils"; import { Vector, VectorIterator } from "./vector"; function serializeIndex(index) { const data = new Uint32Array([index]); diff --git a/lib/collections/vector.js b/lib/collections/vector.js index 980d84683..9a36183b4 100644 --- a/lib/collections/vector.js +++ b/lib/collections/vector.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, str, bytes } from "../utils"; +import { assert, getValueWithOptions, serializeValueWithOptions, ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, str, bytes, } from "../utils"; function indexToKey(prefix, index) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); diff --git a/lib/near-bindgen.js b/lib/near-bindgen.js index c20662aa4..c38597c7c 100644 --- a/lib/near-bindgen.js +++ b/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize, bytes, encode, decode, } from "./utils"; +import { deserialize, serialize, bytes, encode, decode } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * diff --git a/lib/utils.d.ts b/lib/utils.d.ts index bb59fd287..92c705d6e 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -54,7 +54,6 @@ export declare function validateAccountId(accountId: string): boolean; * A subset of NodeJS TextEncoder API */ export declare class TextEncoder { - constructor(); encode(s: string): Uint8Array; } /** diff --git a/lib/utils.js b/lib/utils.js index 61e57c119..fd810fc71 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -105,7 +105,6 @@ export function validateAccountId(accountId) { * A subset of NodeJS TextEncoder API */ export class TextEncoder { - constructor() { } encode(s) { return env.utf8_string_to_uint8array(s); } @@ -114,18 +113,18 @@ export class TextEncoder { * A subset of NodeJS TextDecoder API. Only support utf-8 and latin1 encoding. */ export class TextDecoder { - constructor(encoding = 'utf-8') { + constructor(encoding = "utf-8") { this.encoding = encoding; } decode(a) { - if (this.encoding == 'utf-8') { + if (this.encoding == "utf-8") { return env.uint8array_to_utf8_string(a); } - else if (this.encoding == 'latin1') { + else if (this.encoding == "latin1") { return env.uint8array_to_latin1_string(a); } else { - throw new Error('unsupported encoding: ' + this.encoding); + throw new Error("unsupported encoding: " + this.encoding); } } } diff --git a/src/api.ts b/src/api.ts index d775473d0..ee8e9a9db 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,10 +1,4 @@ -import { - assert, - NearAmount, - PromiseIndex, - Register, - str, -} from "./utils"; +import { assert, NearAmount, PromiseIndex, Register, str } from "./utils"; import { GasWeight, PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; @@ -142,7 +136,7 @@ interface Env { promise_return(promiseIndex: bigint): void; uint8array_to_latin1_string(a: Uint8Array): string; - uint8array_to_utf8_string(a: Uint8Array): string; + uint8array_to_utf8_string(a: Uint8Array): string; latin1_string_to_uint8array(s: string): Uint8Array; utf8_string_to_uint8array(s: string): Uint8Array; } diff --git a/src/build-tools/include-bytes.ts b/src/build-tools/include-bytes.ts index b0f82b111..a47e73014 100644 --- a/src/build-tools/include-bytes.ts +++ b/src/build-tools/include-bytes.ts @@ -56,7 +56,15 @@ export default function (): { visitor: Visitor } { const filePath = join(root, fileRelPath); const fileSrc = readFileSync(filePath, { encoding }).toString(); - path.replaceWith(t.callExpression(t.memberExpression(t.identifier('env'), t.identifier('latin1_string_to_uint8array')), [t.stringLiteral(fileSrc)]) as Node); + path.replaceWith( + t.callExpression( + t.memberExpression( + t.identifier("env"), + t.identifier("latin1_string_to_uint8array") + ), + [t.stringLiteral(fileSrc)] + ) as Node + ); } }, }, diff --git a/src/collections/lookup-map.ts b/src/collections/lookup-map.ts index 6b468113d..7201c198a 100644 --- a/src/collections/lookup-map.ts +++ b/src/collections/lookup-map.ts @@ -3,7 +3,7 @@ import { GetOptions } from "../types/collections"; import { getValueWithOptions, serializeValueWithOptions, - encode + encode, } from "../utils"; /** diff --git a/src/collections/unordered-map.ts b/src/collections/unordered-map.ts index 4451829f7..e7c46fb3e 100644 --- a/src/collections/unordered-map.ts +++ b/src/collections/unordered-map.ts @@ -5,7 +5,7 @@ import { Mutable, serializeValueWithOptions, encode, - decode + decode, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { LookupMap } from "./lookup-map"; @@ -247,7 +247,10 @@ class UnorderedMapIterator { return { done: key.done, - value: [key.value, getValueWithOptions(encode(valueAndIndex[0]), this.options)], + value: [ + key.value, + getValueWithOptions(encode(valueAndIndex[0]), this.options), + ], }; } } diff --git a/src/collections/unordered-set.ts b/src/collections/unordered-set.ts index 891bcdf9d..b3d7fa6ba 100644 --- a/src/collections/unordered-set.ts +++ b/src/collections/unordered-set.ts @@ -3,7 +3,7 @@ import { assert, serializeValueWithOptions, ERR_INCONSISTENT_STATE, - encode + encode, } from "../utils"; import { Vector, VectorIterator } from "./vector"; import { Mutable } from "../utils"; @@ -13,7 +13,7 @@ function serializeIndex(index: number) { const data = new Uint32Array([index]); const array = new Uint8Array(data.buffer); - return array + return array; } function deserializeIndex(rawIndex: Uint8Array): number { diff --git a/src/collections/vector.ts b/src/collections/vector.ts index 5db020234..9e869dc51 100644 --- a/src/collections/vector.ts +++ b/src/collections/vector.ts @@ -6,7 +6,7 @@ import { ERR_INCONSISTENT_STATE, ERR_INDEX_OUT_OF_BOUNDS, str, - bytes + bytes, } from "../utils"; import { GetOptions } from "../types/collections"; @@ -137,7 +137,10 @@ export class Vector { const key = indexToKey(this.prefix, index); assert( - near.storageWrite(bytes(key), serializeValueWithOptions(element, options)), + near.storageWrite( + bytes(key), + serializeValueWithOptions(element, options) + ), ERR_INCONSISTENT_STATE ); diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index 5519133e8..22ba789c9 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -1,11 +1,5 @@ import * as near from "./api"; -import { - deserialize, - serialize, - bytes, - encode, - decode, -} from "./utils"; +import { deserialize, serialize, bytes, encode, decode } from "./utils"; type EmptyParameterObject = Record; type AnyObject = Record; @@ -177,10 +171,7 @@ export function NearBindgen({ } static _saveToStorage(objectToSave: unknown): void { - near.storageWrite( - bytes("STATE"), - this._serialize(objectToSave) - ); + near.storageWrite(bytes("STATE"), this._serialize(objectToSave)); } static _getArgs(): unknown { diff --git a/src/utils.ts b/src/utils.ts index b44d29039..6038c19f3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,7 +2,7 @@ import { GetOptions } from "./types/collections"; export interface Env { uint8array_to_latin1_string(a: Uint8Array): string; - uint8array_to_utf8_string(a: Uint8Array): string; + uint8array_to_utf8_string(a: Uint8Array): string; latin1_string_to_uint8array(s: string): Uint8Array; utf8_string_to_uint8array(s: string): Uint8Array; } @@ -45,10 +45,7 @@ const ACCOUNT_ID_REGEX = * @param array2 * @returns the concatenation of two array */ -export function concat( - array1: Uint8Array, - array2: Uint8Array -): Uint8Array { +export function concat(array1: Uint8Array, array2: Uint8Array): Uint8Array { const mergedArray = new Uint8Array(array1.length + array2.length); mergedArray.set(array1); mergedArray.set(array2, array1.length); @@ -81,7 +78,7 @@ export function getValueWithOptions( if (value === null) { return options?.defaultValue ?? null; } - + const deserialized = deserialize(value); if (deserialized === undefined || deserialized === null) { @@ -167,11 +164,9 @@ export function validateAccountId(accountId: string): boolean { /** * A subset of NodeJS TextEncoder API */ - export class TextEncoder { - constructor() {} - +export class TextEncoder { encode(s: string): Uint8Array { - return env.utf8_string_to_uint8array(s) + return env.utf8_string_to_uint8array(s); } } @@ -179,26 +174,26 @@ export function validateAccountId(accountId: string): boolean { * A subset of NodeJS TextDecoder API. Only support utf-8 and latin1 encoding. */ export class TextDecoder { - constructor(public encoding: string = 'utf-8') {} - + constructor(public encoding: string = "utf-8") {} + decode(a: Uint8Array): string { - if (this.encoding == 'utf-8') { - return env.uint8array_to_utf8_string(a) - } else if (this.encoding == 'latin1') { - return env.uint8array_to_latin1_string(a) + if (this.encoding == "utf-8") { + return env.uint8array_to_utf8_string(a); + } else if (this.encoding == "latin1") { + return env.uint8array_to_latin1_string(a); } else { - throw new Error('unsupported encoding: ' + this.encoding) + throw new Error("unsupported encoding: " + this.encoding); } } } /** - * Convert a string to Uint8Array, each character must have a char code between 0-255. + * Convert a string to Uint8Array, each character must have a char code between 0-255. * @param s - string that with only Latin1 character to convert * @returns result Uint8Array */ export function bytes(s: string): Uint8Array { - return env.latin1_string_to_uint8array(s) + return env.latin1_string_to_uint8array(s); } /** diff --git a/tests/__tests__/bytes.ava.js b/tests/__tests__/bytes.ava.js index af4b4b152..9dbfe97e3 100644 --- a/tests/__tests__/bytes.ava.js +++ b/tests/__tests__/bytes.ava.js @@ -45,7 +45,11 @@ test("Log unexpected types not logging", async (t) => { let r = await ali.callRaw(bytesContract, "log_unexpected_input_tests", ""); // logUtf8 and logUtf16 only works with bytes, trying to log it with string is error - t.assert(r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith('Smart contract panicked: Expect Uint8Array for message')) + t.assert( + r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.startsWith( + "Smart contract panicked: Expect Uint8Array for message" + ) + ); t.deepEqual(r.result.receipts_outcome[0].outcome.logs, []); }); @@ -113,11 +117,8 @@ test("storage write utf8, utf8 string convert to Uint8Array tests", async (t) => const { ali, bytesContract } = t.context.accounts; await ali.call(bytesContract, "storage_write_utf8", ""); - let r = await bytesContract.viewRaw( - "storage_read_utf8", - "" - ); - t.deepEqual(r.result, [...Buffer.from('😂', 'utf-8')]); + let r = await bytesContract.viewRaw("storage_read_utf8", ""); + t.deepEqual(r.result, [...Buffer.from("😂", "utf-8")]); }); test("Storage read bytes tests", async (t) => { @@ -203,20 +204,32 @@ test("panic tests", async (t) => { test("utf8 string can be convert to Uint8Array correctly", async (t) => { const { bob, bytesContract } = t.context.accounts; - let res = await bob.callRaw(bytesContract, "utf8_string_to_uint8array_tests", ""); - t.is(res.result.status.SuccessValue, '') -}) + let res = await bob.callRaw( + bytesContract, + "utf8_string_to_uint8array_tests", + "" + ); + t.is(res.result.status.SuccessValue, ""); +}); test("valid utf8 sequence can be convert to string correctly", async (t) => { const { bob, bytesContract } = t.context.accounts; - let res = await bob.callRaw(bytesContract, "uint8array_to_utf8_string_tests", ""); - t.is(res.result.status.SuccessValue, '') -}) + let res = await bob.callRaw( + bytesContract, + "uint8array_to_utf8_string_tests", + "" + ); + t.is(res.result.status.SuccessValue, ""); +}); test("latin1 sequence can be convert to string correctly", async (t) => { const { bob, bytesContract } = t.context.accounts; - let res = await bob.callRaw(bytesContract, "uint8array_to_latin1_string_tests", ""); - t.is(res.result.status.SuccessValue, '') -}) + let res = await bob.callRaw( + bytesContract, + "uint8array_to_latin1_string_tests", + "" + ); + t.is(res.result.status.SuccessValue, ""); +}); diff --git a/tests/__tests__/lookup-map.ava.js b/tests/__tests__/lookup-map.ava.js index 2e26a9abf..f4ff27181 100644 --- a/tests/__tests__/lookup-map.ava.js +++ b/tests/__tests__/lookup-map.ava.js @@ -94,20 +94,23 @@ test("LookupMap allows you to use the same key for the second time", async (t) = }); test.only("UTF-8 in arguments, store in collections & state, return in returns", async (t) => { - const {ali, lookupMapContract} = t.context.accounts; + const { ali, lookupMapContract } = t.context.accounts; let data = { - "utf8emoji": "😂", - "utf8char": "水", + utf8emoji: "😂", + utf8char: "水", // this is the byte sequence of above utf8 char, it will be escaped in js contract // so it won't be mis-recorgnized as above utf8 char. - "utf8char_charcode_seq": "\xe6\xb0\xb4", + utf8char_charcode_seq: "\xe6\xb0\xb4", // this and above shows arbitrary binary data can be put in arguments, state and return // default serialization and deserialization works - "latin1_charcode_seq": "\xc2\x00\x01\xff" - } - let res = await ali.callRaw(lookupMapContract, "set", {key: "utf8test", value: data}) - t.is(res.result.status.SuccessValue, '') + latin1_charcode_seq: "\xc2\x00\x01\xff", + }; + let res = await ali.callRaw(lookupMapContract, "set", { + key: "utf8test", + value: data, + }); + t.is(res.result.status.SuccessValue, ""); t.deepEqual(await lookupMapContract.view("get", { key: "utf8test" }), data); -}) \ No newline at end of file +}); diff --git a/tests/__tests__/test_highlevel_promise.ava.js b/tests/__tests__/test_highlevel_promise.ava.js index ed1e64470..6ec8c2718 100644 --- a/tests/__tests__/test_highlevel_promise.ava.js +++ b/tests/__tests__/test_highlevel_promise.ava.js @@ -169,7 +169,8 @@ test("cross contract call success then call a panic method", async (t) => { ); // the last promise fail, cause the transaction fail console.log( - r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError) + r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError + ); t.assert( r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.includes( "Smart contract panicked: it just panic" diff --git a/tests/__tests__/test_promise_api.ava.js b/tests/__tests__/test_promise_api.ava.js index 69787e421..80b7d5803 100644 --- a/tests/__tests__/test_promise_api.ava.js +++ b/tests/__tests__/test_promise_api.ava.js @@ -234,7 +234,7 @@ test("promise batch deploy contract and call", async (t) => { "", { gas: "300 Tgas" } ); - console.log(JSON.stringify(r, null, 2)) + console.log(JSON.stringify(r, null, 2)); let deployed = caller2Contract.getSubAccount("b"); t.deepEqual(JSON.parse(Buffer.from(r.result.status.SuccessValue, "base64")), { diff --git a/tests/src/bytes.js b/tests/src/bytes.js index 7f28fb01a..f7d340df3 100644 --- a/tests/src/bytes.js +++ b/tests/src/bytes.js @@ -44,7 +44,7 @@ export function storage_write_utf8() { } export function storage_read_utf8() { - near.valueReturn(near.storageRead(encode("水"))) + near.valueReturn(near.storageRead(encode("水"))); } export function storage_read_ascii_bytes() { @@ -92,63 +92,66 @@ export function panicUtf8_invalid_utf8_sequence() { } const areEqual = (first, second) => - first.length === second.length && first.every((value, index) => value === second[index]); + first.length === second.length && + first.every((value, index) => value === second[index]); export function utf8_string_to_uint8array_tests() { - let utf8chars = '水😂' - let withUtf8CharCodeSeq = '\xe6\xb0\xb4' - let withArbitraryLatinSeq = '\x00\x01\xff' - - assert(areEqual(encode(utf8chars), new Uint8Array([ - 230, 176, 180, - 240, 159, 152, - 130 - ]))) - assert(areEqual(encode(withUtf8CharCodeSeq), new Uint8Array( - [ 195, 166, 194, 176, 194, 180 ] - ))) - assert(areEqual(encode(withArbitraryLatinSeq), new Uint8Array([ 0, 1, 195, 191 ]))) - - assert(decode(encode(utf8chars)) == utf8chars) - assert(decode(encode(withUtf8CharCodeSeq)) == withUtf8CharCodeSeq) - assert(decode(encode(withArbitraryLatinSeq)) == withArbitraryLatinSeq) + let utf8chars = "水😂"; + let withUtf8CharCodeSeq = "\xe6\xb0\xb4"; + let withArbitraryLatinSeq = "\x00\x01\xff"; + + assert( + areEqual( + encode(utf8chars), + new Uint8Array([230, 176, 180, 240, 159, 152, 130]) + ) + ); + assert( + areEqual( + encode(withUtf8CharCodeSeq), + new Uint8Array([195, 166, 194, 176, 194, 180]) + ) + ); + assert( + areEqual(encode(withArbitraryLatinSeq), new Uint8Array([0, 1, 195, 191])) + ); + + assert(decode(encode(utf8chars)) == utf8chars); + assert(decode(encode(withUtf8CharCodeSeq)) == withUtf8CharCodeSeq); + assert(decode(encode(withArbitraryLatinSeq)) == withArbitraryLatinSeq); } export function uint8array_to_utf8_string_tests() { - let validUtf8SeqArray = new Uint8Array([ - 230, 176, 180, - 240, 159, 152, - 130 - ]) - let escapedUtf8SeqArray = new Uint8Array( - [ 195, 166, 194, 176, 194, 180 ] - ) - let invalidUtf8Seq = new Uint8Array([ 0, 1, 255 ]) - - assert(decode(validUtf8SeqArray) == '水😂') - assert(decode(escapedUtf8SeqArray) == '\xe6\xb0\xb4') + let validUtf8SeqArray = new Uint8Array([230, 176, 180, 240, 159, 152, 130]); + let escapedUtf8SeqArray = new Uint8Array([195, 166, 194, 176, 194, 180]); + let invalidUtf8Seq = new Uint8Array([0, 1, 255]); + + assert(decode(validUtf8SeqArray) == "水😂"); + assert(decode(escapedUtf8SeqArray) == "\xe6\xb0\xb4"); // same behavior as nodejs - assert(decode(invalidUtf8Seq) == '\x00\x01\ufffd') + assert(decode(invalidUtf8Seq) == "\x00\x01\ufffd"); - assert(areEqual(encode(decode(validUtf8SeqArray)), validUtf8SeqArray)) - assert(areEqual(encode(decode(escapedUtf8SeqArray)), escapedUtf8SeqArray)) + assert(areEqual(encode(decode(validUtf8SeqArray)), validUtf8SeqArray)); + assert(areEqual(encode(decode(escapedUtf8SeqArray)), escapedUtf8SeqArray)); // same behavior as nodejs - assert(areEqual(encode(decode(invalidUtf8Seq)), new Uint8Array([0,1,239,191,189]))) + assert( + areEqual( + encode(decode(invalidUtf8Seq)), + new Uint8Array([0, 1, 239, 191, 189]) + ) + ); } export function uint8array_to_latin1_string_tests() { - let happensToBeUtf8Seq = new Uint8Array([ - 230, 176, 180, - ]) - let validLatin1InvalidUtf8 = new Uint8Array([ 0, 1, 255 ]) - let ascii = new Uint8Array([65, 66, 67]) - - assert(str(happensToBeUtf8Seq) == '\xe6\xb0\xb4') - assert(str(validLatin1InvalidUtf8) == '\x00\x01\xff') - assert(str(ascii) == '\x41\x42\x43') + let happensToBeUtf8Seq = new Uint8Array([230, 176, 180]); + let validLatin1InvalidUtf8 = new Uint8Array([0, 1, 255]); + let ascii = new Uint8Array([65, 66, 67]); - assert(areEqual(bytes(str(happensToBeUtf8Seq)), happensToBeUtf8Seq)) - assert(areEqual(bytes(str(validLatin1InvalidUtf8)), validLatin1InvalidUtf8)) - assert(areEqual(bytes(str(ascii)), ascii)) + assert(str(happensToBeUtf8Seq) == "\xe6\xb0\xb4"); + assert(str(validLatin1InvalidUtf8) == "\x00\x01\xff"); + assert(str(ascii) == "\x41\x42\x43"); + assert(areEqual(bytes(str(happensToBeUtf8Seq)), happensToBeUtf8Seq)); + assert(areEqual(bytes(str(validLatin1InvalidUtf8)), validLatin1InvalidUtf8)); + assert(areEqual(bytes(str(ascii)), ascii)); } diff --git a/tests/src/public-key.js b/tests/src/public-key.js index 27bb3700c..2aff98605 100644 --- a/tests/src/public-key.js +++ b/tests/src/public-key.js @@ -16,13 +16,13 @@ export function test_add_signer_key() { export function test_add_ed25519_key_bytes() { let pk = new PublicKey( - new Uint8Array([ - // CurveType.ED25519 = 0 - 0, - // ED25519 PublicKey data - 186, 44, 216, 49, 157, 48, 151, 47, 23, 244, 137, 69, 78, 150, 54, 42, - 30, 248, 110, 26, 205, 18, 137, 154, 10, 208, 26, 183, 65, 166, 223, 18, - ]) + new Uint8Array([ + // CurveType.ED25519 = 0 + 0, + // ED25519 PublicKey data + 186, 44, 216, 49, 157, 48, 151, 47, 23, 244, 137, 69, 78, 150, 54, 42, 30, + 248, 110, 26, 205, 18, 137, 154, 10, 208, 26, 183, 65, 166, 223, 18, + ]) ); runtime_validate_public_key("a", pk.data); } @@ -35,16 +35,15 @@ export function test_add_ed25519_key_string() { export function test_add_secp256k1_key_bytes() { let pk = new PublicKey( - new Uint8Array([ - // CurveType.SECP256K1 = 1 - 1, - // SECP256K1 PublicKey data - 242, 86, 198, 230, 200, 11, 33, 63, 42, 160, 176, 23, 68, 35, 93, 81, - 92, 89, 68, 53, 190, 101, 27, 21, 136, 58, 16, 221, 71, 47, 166, 70, - 206, 98, 234, 243, 103, 13, 197, 203, 145, 0, 160, 202, 42, 85, 178, - 193, 71, 193, 233, 163, 140, 228, 40, 135, 142, 125, 70, 225, 251, 113, - 74, 153, - ]) + new Uint8Array([ + // CurveType.SECP256K1 = 1 + 1, + // SECP256K1 PublicKey data + 242, 86, 198, 230, 200, 11, 33, 63, 42, 160, 176, 23, 68, 35, 93, 81, 92, + 89, 68, 53, 190, 101, 27, 21, 136, 58, 16, 221, 71, 47, 166, 70, 206, 98, + 234, 243, 103, 13, 197, 203, 145, 0, 160, 202, 42, 85, 178, 193, 71, 193, + 233, 163, 140, 228, 40, 135, 142, 125, 70, 225, 251, 113, 74, 153, + ]) ); runtime_validate_public_key("c", pk.data); } From 9263d61e0cd9731b6238f778eec5893a9d2e6a2f Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 7 Dec 2022 14:56:30 +0800 Subject: [PATCH 17/24] fix clean-state cross contract call loop, ft and programmatic update example --- examples/src/clean-state.js | 12 ++++++++---- examples/src/cross-contract-call-loop.js | 6 +++--- examples/src/fungible-token.ts | 3 ++- examples/src/programmatic-update-after.ts | 6 +++--- examples/src/programmatic-update-before.ts | 6 +++--- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/src/clean-state.js b/examples/src/clean-state.js index 7021a6097..107a9b8d3 100644 --- a/examples/src/clean-state.js +++ b/examples/src/clean-state.js @@ -1,19 +1,23 @@ -import { NearBindgen, call, view, near } from "near-sdk-js"; +import { NearBindgen, call, view, near, encode, decode } from "near-sdk-js"; @NearBindgen({}) export class CleanState { @call({}) clean({ keys }) { - keys.forEach((key) => near.storageRemove(key)); + keys.forEach((key) => near.storageRemove(encode(key))); } @call({}) put({ key, value }) { - near.storageWrite(key, value); + near.storageWrite(encode(key), encode(value)); } @view({}) get({ key }) { - return near.storageRead(key); + let raw = near.storageRead(encode(key)); + if (raw !== null) { + return decode(raw) + } + return null } } diff --git a/examples/src/cross-contract-call-loop.js b/examples/src/cross-contract-call-loop.js index bd46e6d71..1172a444d 100644 --- a/examples/src/cross-contract-call-loop.js +++ b/examples/src/cross-contract-call-loop.js @@ -1,11 +1,11 @@ -import { call, near, NearBindgen, NearPromise, view } from "near-sdk-js"; +import { call, near, NearBindgen, NearPromise, view, decode } from "near-sdk-js"; const CONTRACTS = [ "first-contract.test.near", "second-contract.test.near", "third-contract.test.near", ]; -const NO_ARGS = ""; +const NO_ARGS = new Uint8Array(); const THIRTY_TGAS = BigInt("30" + "0".repeat(12)); @NearBindgen({}) @@ -48,7 +48,7 @@ export class LoopXCC { const callCount = near.promiseResultsCount(); for (let i = 0; i < callCount; i++) { const promiseResult = near.promiseResult(i); - const result = JSON.parse(promiseResult); + const result = JSON.parse(decode(promiseResult)); this.count += result; } return this.count; diff --git a/examples/src/fungible-token.ts b/examples/src/fungible-token.ts index 8a4aa7ee6..2600798fa 100644 --- a/examples/src/fungible-token.ts +++ b/examples/src/fungible-token.ts @@ -7,6 +7,7 @@ import { LookupMap, assert, validateAccountId, + encode } from "near-sdk-js"; @NearBindgen({ requireInit: true }) @@ -209,7 +210,7 @@ export class FungibleToken { near.promiseBatchActionFunctionCall( promise, "ft_on_transfer", - JSON.stringify(params), + encode(JSON.stringify(params)), 0, 30000000000000 ); diff --git a/examples/src/programmatic-update-after.ts b/examples/src/programmatic-update-after.ts index 9fa00e7a0..dfb4e27c3 100644 --- a/examples/src/programmatic-update-after.ts +++ b/examples/src/programmatic-update-after.ts @@ -1,4 +1,4 @@ -import { NearBindgen, near, initialize, assert, view } from "near-sdk-js"; +import { NearBindgen, near, initialize, assert, view, bytes, str } from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateAfter { @@ -7,7 +7,7 @@ export class ProgrammaticUpdateAfter { @initialize({ privateFunction: true }) init({ manager }: { manager: string }) { near.log(`Setting manager to be ${manager}`); - near.storageWrite("MANAGER", manager); + near.storageWrite(bytes("MANAGER"), bytes(manager)); } @view({}) // Method renamed and return "Hi" when greeting is "Hello" @@ -17,7 +17,7 @@ export class ProgrammaticUpdateAfter { } export function updateContract() { - const manager = near.storageRead("MANAGER"); + const manager = str(near.storageRead(bytes("MANAGER"))); assert( near.predecessorAccountId() === manager, "Only the manager can update the code" diff --git a/examples/src/programmatic-update-before.ts b/examples/src/programmatic-update-before.ts index cae836077..ac4c1956a 100644 --- a/examples/src/programmatic-update-before.ts +++ b/examples/src/programmatic-update-before.ts @@ -1,4 +1,4 @@ -import { NearBindgen, near, initialize, assert, view } from "near-sdk-js"; +import { NearBindgen, near, initialize, assert, view, bytes, str } from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateBefore { @@ -7,7 +7,7 @@ export class ProgrammaticUpdateBefore { @initialize({ privateFunction: true }) init({ manager }: { manager: string }) { near.log(`Setting manager to be ${manager}`); - near.storageWrite("MANAGER", manager); + near.storageWrite(bytes("MANAGER"), bytes(manager)); } @view({}) // This method will be renamed after update and will return "Hi" if greeting is "Hello" @@ -17,7 +17,7 @@ export class ProgrammaticUpdateBefore { } export function updateContract() { - const manager = near.storageRead("MANAGER"); + const manager = str(near.storageRead(bytes("MANAGER"))); assert( near.predecessorAccountId() === manager, "Only the manager can update the code" From 4e85aba43d7944e30be5a3bffb205b17add0a190 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 7 Dec 2022 17:34:27 +0800 Subject: [PATCH 18/24] fixing my-nft.ts build --- examples/src/standard-nft/my-nft.ts | 18 +++++++++--------- .../lib/non_fungible_token/utils.d.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/src/standard-nft/my-nft.ts b/examples/src/standard-nft/my-nft.ts index a585ac6b7..2b0d66f13 100644 --- a/examples/src/standard-nft/my-nft.ts +++ b/examples/src/standard-nft/my-nft.ts @@ -1,7 +1,7 @@ import { NonFungibleToken } from "near-contract-standards/lib"; import { assert, - Bytes, + bytes, call, initialize, near, @@ -32,26 +32,26 @@ import { NonFungibleTokenEnumeration } from "near-contract-standards/lib/non_fun class StorageKey {} class StorageKeyNonFungibleToken extends StorageKey implements IntoStorageKey { - into_storage_key(): Bytes { - return "NFT_"; + into_storage_key(): Uint8Array { + return bytes("NFT_"); } } class StorageKeyTokenMetadata extends StorageKey implements IntoStorageKey { - into_storage_key(): Bytes { - return "TOKEN_METADATA_"; + into_storage_key(): Uint8Array { + return bytes("TOKEN_METADATA_"); } } class StorageKeyTokenEnumeration extends StorageKey implements IntoStorageKey { - into_storage_key(): Bytes { - return "TOKEN_ENUMERATION_"; + into_storage_key(): Uint8Array { + return bytes("TOKEN_ENUMERATION_"); } } class StorageKeyApproval extends StorageKey implements IntoStorageKey { - into_storage_key(): Bytes { - return "APPROVAL1_"; + into_storage_key(): Uint8Array { + return bytes("APPROVAL1_"); } } diff --git a/near-contract-standards/lib/non_fungible_token/utils.d.ts b/near-contract-standards/lib/non_fungible_token/utils.d.ts index dd2715520..d787dc4c0 100644 --- a/near-contract-standards/lib/non_fungible_token/utils.d.ts +++ b/near-contract-standards/lib/non_fungible_token/utils.d.ts @@ -10,5 +10,5 @@ export declare function assert_at_least_one_yocto(): void; export declare function assert_one_yocto(): void; export declare type Option = T | null; export interface IntoStorageKey { - into_storage_key(): Bytes; + into_storage_key(): Uint8Array; } From 493ce7137e67834d54a84915dd84298b60396b01 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 8 Dec 2022 16:43:37 +0800 Subject: [PATCH 19/24] fix all examples --- .../__tests__/test-cross-contract-call.ava.js | 3 +- examples/src/clean-state.js | 4 +- examples/src/cross-contract-call-loop.js | 9 ++- examples/src/cross-contract-call.js | 12 +++- examples/src/fungible-token.ts | 2 +- examples/src/non-fungible-token.js | 3 +- examples/src/programmatic-update-after.ts | 10 +++- examples/src/programmatic-update-before.ts | 10 +++- .../standard-nft/test-approval-receiver.ts | 3 +- .../src/standard-nft/test-token-receiver.ts | 5 +- .../lib/non_fungible_token/impl.d.ts | 14 ++--- .../lib/non_fungible_token/impl.js | 28 +++++---- .../lib/non_fungible_token/metadata.d.ts | 60 +++++++++---------- .../lib/non_fungible_token/metadata.js | 20 +++---- .../lib/non_fungible_token/utils.d.ts | 4 +- .../lib/non_fungible_token/utils.js | 4 +- .../src/non_fungible_token/impl.ts | 47 +++++++++------ .../src/non_fungible_token/metadata.ts | 10 ++-- .../src/non_fungible_token/utils.ts | 8 +-- 19 files changed, 149 insertions(+), 107 deletions(-) diff --git a/examples/__tests__/test-cross-contract-call.ava.js b/examples/__tests__/test-cross-contract-call.ava.js index 55308c930..65b1f2e6d 100644 --- a/examples/__tests__/test-cross-contract-call.ava.js +++ b/examples/__tests__/test-cross-contract-call.ava.js @@ -52,12 +52,13 @@ test("Person can be set on-call if AVAILABLE", async (t) => { // Ali set her status as AVAILABLE await ali.call(statusMessage, "set_status", { message: "AVAILABLE" }); // Bob sets Ali on-call - await bob.call( + let r = await bob.callRaw( onCall, "set_person_on_call", { accountId: ali.accountId }, { gas: 120000000000000 } ); + console.log(JSON.stringify(r, null, 2)); // Check that Ali is on-call t.is(await onCall.view("person_on_call", {}), ali.accountId); diff --git a/examples/src/clean-state.js b/examples/src/clean-state.js index 107a9b8d3..827328dbd 100644 --- a/examples/src/clean-state.js +++ b/examples/src/clean-state.js @@ -16,8 +16,8 @@ export class CleanState { get({ key }) { let raw = near.storageRead(encode(key)); if (raw !== null) { - return decode(raw) + return decode(raw); } - return null + return null; } } diff --git a/examples/src/cross-contract-call-loop.js b/examples/src/cross-contract-call-loop.js index 1172a444d..f67c78332 100644 --- a/examples/src/cross-contract-call-loop.js +++ b/examples/src/cross-contract-call-loop.js @@ -1,4 +1,11 @@ -import { call, near, NearBindgen, NearPromise, view, decode } from "near-sdk-js"; +import { + call, + near, + NearBindgen, + NearPromise, + view, + decode, +} from "near-sdk-js"; const CONTRACTS = [ "first-contract.test.near", diff --git a/examples/src/cross-contract-call.js b/examples/src/cross-contract-call.js index 2272e81fd..0d12fa856 100644 --- a/examples/src/cross-contract-call.js +++ b/examples/src/cross-contract-call.js @@ -1,4 +1,12 @@ -import { NearBindgen, call, view, initialize, near, bytes } from "near-sdk-js"; +import { + NearBindgen, + call, + view, + initialize, + near, + bytes, + str, +} from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class OnCall { @@ -37,7 +45,7 @@ export class OnCall { @call({ privateFunction: true }) _set_person_on_call_private({ accountId }) { near.log(`_set_person_on_call_private called, accountId ${accountId}`); - const status = JSON.parse(near.promiseResult(0)); + const status = JSON.parse(str(near.promiseResult(0))); near.log(`${accountId} status is ${status}`); if (status === "AVAILABLE") { this.personOnCall = accountId; diff --git a/examples/src/fungible-token.ts b/examples/src/fungible-token.ts index 2600798fa..37b4f36a7 100644 --- a/examples/src/fungible-token.ts +++ b/examples/src/fungible-token.ts @@ -7,7 +7,7 @@ import { LookupMap, assert, validateAccountId, - encode + encode, } from "near-sdk-js"; @NearBindgen({ requireInit: true }) diff --git a/examples/src/non-fungible-token.js b/examples/src/non-fungible-token.js index c81637d10..3718ce040 100644 --- a/examples/src/non-fungible-token.js +++ b/examples/src/non-fungible-token.js @@ -7,6 +7,7 @@ import { LookupMap, bytes, assert, + str, } from "near-sdk-js"; class Token { @@ -103,7 +104,7 @@ export class NftContract { near.log( `_nftResolveTransfer called, receiver_id ${receiver_id}, token_id ${token_id}` ); - const isTokenTransfered = JSON.parse(near.promiseResult(0)); + const isTokenTransfered = JSON.parse(str(near.promiseResult(0))); near.log( `${token_id} ${ isTokenTransfered ? "was transfered" : "was NOT transfered" diff --git a/examples/src/programmatic-update-after.ts b/examples/src/programmatic-update-after.ts index dfb4e27c3..8d3e05965 100644 --- a/examples/src/programmatic-update-after.ts +++ b/examples/src/programmatic-update-after.ts @@ -1,4 +1,12 @@ -import { NearBindgen, near, initialize, assert, view, bytes, str } from "near-sdk-js"; +import { + NearBindgen, + near, + initialize, + assert, + view, + bytes, + str, +} from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateAfter { diff --git a/examples/src/programmatic-update-before.ts b/examples/src/programmatic-update-before.ts index ac4c1956a..54993d80e 100644 --- a/examples/src/programmatic-update-before.ts +++ b/examples/src/programmatic-update-before.ts @@ -1,4 +1,12 @@ -import { NearBindgen, near, initialize, assert, view, bytes, str } from "near-sdk-js"; +import { + NearBindgen, + near, + initialize, + assert, + view, + bytes, + str, +} from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateBefore { diff --git a/examples/src/standard-nft/test-approval-receiver.ts b/examples/src/standard-nft/test-approval-receiver.ts index 640737c14..9216cc437 100644 --- a/examples/src/standard-nft/test-approval-receiver.ts +++ b/examples/src/standard-nft/test-approval-receiver.ts @@ -6,7 +6,6 @@ import { PromiseOrValue, assert, call, - bytes, serialize, } from "near-sdk-js"; import { AccountId } from "near-sdk-js"; @@ -58,7 +57,7 @@ export class ApprovalReceiver const account_id = near.currentAccountId(); return NearPromise.new(account_id).functionCall( "ok_go", - bytes(serialize({ msg })), + serialize({ msg }), 0n, prepaid_gas - GAS_FOR_NFT_ON_APPROVE ); diff --git a/examples/src/standard-nft/test-token-receiver.ts b/examples/src/standard-nft/test-token-receiver.ts index 40433aa64..a75a8c5cd 100644 --- a/examples/src/standard-nft/test-token-receiver.ts +++ b/examples/src/standard-nft/test-token-receiver.ts @@ -7,7 +7,6 @@ import { NearBindgen, NearPromise, PromiseOrValue, - bytes, serialize, } from "near-sdk-js"; import { AccountId } from "near-sdk-js"; @@ -66,7 +65,7 @@ export class TokenReceiver const account_id = near.currentAccountId(); return NearPromise.new(account_id).functionCall( "ok_go", - bytes(serialize({ return_it: true })), + serialize({ return_it: true }), 0n, prepaid_gas - GAS_FOR_NFT_ON_TRANSFER ); @@ -78,7 +77,7 @@ export class TokenReceiver const account_id = near.currentAccountId(); return NearPromise.new(account_id).functionCall( "ok_go", - bytes(serialize({ return_it: false })), + serialize({ return_it: false }), 0n, prepaid_gas - GAS_FOR_NFT_ON_TRANSFER ); diff --git a/near-contract-standards/lib/non_fungible_token/impl.d.ts b/near-contract-standards/lib/non_fungible_token/impl.d.ts index f4500d937..56d1b718e 100644 --- a/near-contract-standards/lib/non_fungible_token/impl.d.ts +++ b/near-contract-standards/lib/non_fungible_token/impl.d.ts @@ -1,4 +1,4 @@ -import { AccountId, UnorderedMap, LookupMap, Bytes, UnorderedSet, NearPromise } from "near-sdk-js"; +import { AccountId, UnorderedMap, LookupMap, UnorderedSet, NearPromise } from "near-sdk-js"; import { TokenMetadata } from "./metadata"; import { IntoStorageKey, Option } from "./utils"; import { NonFungibleTokenResolver } from "./core/resolver"; @@ -95,12 +95,12 @@ export declare class NonFungibleToken implements NonFungibleTokenCore, NonFungib } export declare type StorageKey = TokensPerOwner | TokenPerOwnerInner; export declare class TokensPerOwner implements IntoStorageKey { - account_hash: Bytes; - constructor(account_hash: Bytes); - into_storage_key(): Bytes; + account_hash: Uint8Array; + constructor(account_hash: Uint8Array); + into_storage_key(): Uint8Array; } export declare class TokenPerOwnerInner implements IntoStorageKey { - account_id_hash: Bytes; - constructor(account_id_hash: Bytes); - into_storage_key(): Bytes; + account_id_hash: Uint8Array; + constructor(account_id_hash: Uint8Array); + into_storage_key(): Uint8Array; } diff --git a/near-contract-standards/lib/non_fungible_token/impl.js b/near-contract-standards/lib/non_fungible_token/impl.js index 3c98d0eb0..7d8293d9b 100644 --- a/near-contract-standards/lib/non_fungible_token/impl.js +++ b/near-contract-standards/lib/non_fungible_token/impl.js @@ -1,4 +1,4 @@ -import { UnorderedMap, LookupMap, near, UnorderedSet, assert, NearPromise, bytes, serialize, } from "near-sdk-js"; +import { UnorderedMap, LookupMap, near, UnorderedSet, assert, NearPromise, bytes, serialize, str, concat, } from "near-sdk-js"; import { TokenMetadata } from "./metadata"; import { refund_storage_deposit, refund_deposit, refund_deposit_to_account, assert_at_least_one_yocto, assert_one_yocto, } from "./utils"; import { NftMint, NftTransfer } from "./events"; @@ -114,7 +114,7 @@ export class NonFungibleToken { const storage_used = new_approved_account_ids_size - old_approved_account_ids_size; refund_deposit(BigInt(storage_used)); if (msg) { - return NearPromise.new(account_id).functionCall("nft_on_approve", bytes(serialize({ token_id, owner_id, approval_id, msg })), 0n, near.prepaidGas() - GAS_FOR_NFT_APPROVE); + return NearPromise.new(account_id).functionCall("nft_on_approve", serialize({ token_id, owner_id, approval_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_APPROVE); } return null; } @@ -182,8 +182,8 @@ export class NonFungibleToken { let next_approval_id_by_id; if (approval_prefix) { const prefix = approval_prefix.into_storage_key(); - approvals_by_id = new LookupMap(prefix); - next_approval_id_by_id = new LookupMap(prefix + "n"); + approvals_by_id = new LookupMap(str(prefix)); + next_approval_id_by_id = new LookupMap(str(prefix) + "n"); } else { approvals_by_id = null; @@ -191,11 +191,13 @@ export class NonFungibleToken { } this.owner_id = owner_id; this.extra_storage_in_bytes_per_token = 0n; - this.owner_by_id = new UnorderedMap(owner_by_id_prefix.into_storage_key()); + this.owner_by_id = new UnorderedMap(str(owner_by_id_prefix.into_storage_key())); this.token_metadata_by_id = token_metadata_prefix - ? new LookupMap(token_metadata_prefix.into_storage_key()) + ? new LookupMap(str(token_metadata_prefix.into_storage_key())) + : null; + this.tokens_per_owner = enumeration_prefix + ? new LookupMap(str(enumeration_prefix.into_storage_key())) : null; - this.tokens_per_owner = enumeration_prefix ? new LookupMap(enumeration_prefix.into_storage_key()) : null; this.approvals_by_id = approvals_by_id; this.next_approval_id_by_id = next_approval_id_by_id; this.measure_min_token_storage_cost(); @@ -229,7 +231,7 @@ export class NonFungibleToken { this.token_metadata_by_id.set(tmp_token_id, new TokenMetadata(repeat("a", 64), repeat("a", 64), repeat("a", 64), repeat("a", 64), 1n, null, null, null, null, null, null, null)); } if (this.tokens_per_owner) { - const u = new UnorderedSet(new TokensPerOwner(near.sha256(tmp_owner_id)).into_storage_key()); + const u = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(tmp_owner_id))).into_storage_key())); u.set(tmp_token_id); this.tokens_per_owner.set(tmp_owner_id, u); } @@ -282,7 +284,7 @@ export class NonFungibleToken { reconstructor: UnorderedSet.reconstruct, }); if (receiver_tokens_set === null) { - receiver_tokens_set = new UnorderedSet(new TokensPerOwner(near.sha256(to)).into_storage_key()); + receiver_tokens_set = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(to))).into_storage_key())); } receiver_tokens_set.set(token_id); this.tokens_per_owner.set(to, receiver_tokens_set); @@ -341,7 +343,7 @@ export class NonFungibleToken { reconstructor: UnorderedSet.reconstruct, }); if (token_ids === null) { - token_ids = new UnorderedSet(new TokensPerOwner(near.sha256(owner_id)).into_storage_key()); + token_ids = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(owner_id))).into_storage_key())); } token_ids.set(token_id); this.tokens_per_owner.set(owner_id, token_ids); @@ -388,7 +390,7 @@ export class NonFungibleToken { let must_revert = false; let p; try { - p = near.promiseResult(0); + p = str(near.promiseResult(0)); } catch (e) { if (e.message.includes("Not Ready")) { @@ -446,7 +448,7 @@ export class TokensPerOwner { this.account_hash = account_hash; } into_storage_key() { - return "\x00" + this.account_hash; + return concat(bytes("\x00"), this.account_hash); } } export class TokenPerOwnerInner { @@ -454,6 +456,6 @@ export class TokenPerOwnerInner { this.account_id_hash = account_id_hash; } into_storage_key() { - return "\x01" + this.account_id_hash; + return concat(bytes("\x01"), this.account_id_hash); } } diff --git a/near-contract-standards/lib/non_fungible_token/metadata.d.ts b/near-contract-standards/lib/non_fungible_token/metadata.d.ts index 614747f37..6fd6cccef 100644 --- a/near-contract-standards/lib/non_fungible_token/metadata.d.ts +++ b/near-contract-standards/lib/non_fungible_token/metadata.d.ts @@ -1,4 +1,4 @@ -import { Bytes } from "near-sdk-js"; +import { Option } from "./utils"; /** This spec can be treated like a version of the standard. */ export declare const NFT_METADATA_SPEC = "nft-1.0.0"; /** Metadata for the NFT contract itself. */ @@ -6,41 +6,41 @@ export declare class NFTContractMetadata { spec: string; name: string; symbol: string; - icon?: string; - base_uri?: string; - reference?: string; - reference_hash?: Bytes; + icon: Option; + base_uri: Option; + reference: Option; + reference_hash: Option; constructor(); - init(spec: string, name: string, symbol: string, icon?: string, base_uri?: string, reference?: string, reference_hash?: Bytes): void; + init(spec: string, name: string, symbol: string, icon: Option, base_uri: Option, reference: Option, reference_hash: Option): void; assert_valid(): void; static reconstruct(data: NFTContractMetadata): NFTContractMetadata; } /** Metadata on the individual token level. */ export declare class TokenMetadata { - title?: string; - description?: string; - media?: string; - media_hash?: Bytes; - copies?: bigint; - issued_at?: string; - expires_at?: string; - starts_at?: string; - updated_at?: string; - extra?: string; - reference?: string; - reference_hash?: Bytes; - constructor(title?: string, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - description?: string, // free-form description - media?: string, // URL to associated media, preferably to decentralized, content-addressed storage - media_hash?: Bytes, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - copies?: bigint, // number of copies of this set of metadata in existence when token was minted. - issued_at?: string, // ISO 8601 datetime when token was issued or minted - expires_at?: string, // ISO 8601 datetime when token expires - starts_at?: string, // ISO 8601 datetime when token starts being valid - updated_at?: string, // ISO 8601 datetime when token was last updated - extra?: string, // anything extra the NFT wants to store on-chain. Can be stringified JSON. - reference?: string, // URL to an off-chain JSON file with more info. - reference_hash?: Bytes); + title: Option; + description: Option; + media: Option; + media_hash: Option; + copies: Option; + issued_at: Option; + expires_at: Option; + starts_at: Option; + updated_at: Option; + extra: Option; + reference: Option; + reference_hash: Option; + constructor(title: Option, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + description: Option, // free-form description + media: Option, // URL to associated media, preferably to decentralized, content-addressed storage + media_hash: Option, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + copies: Option, // number of copies of this set of metadata in existence when token was minted. + issued_at: Option, // ISO 8601 datetime when token was issued or minted + expires_at: Option, // ISO 8601 datetime when token expires + starts_at: Option, // ISO 8601 datetime when token starts being valid + updated_at: Option, // ISO 8601 datetime when token was last updated + extra: Option, // anything extra the NFT wants to store on-chain. Can be stringified JSON. + reference: Option, // URL to an off-chain JSON file with more info. + reference_hash: Option); assert_valid(): void; static reconstruct(data: TokenMetadata): TokenMetadata; } diff --git a/near-contract-standards/lib/non_fungible_token/metadata.js b/near-contract-standards/lib/non_fungible_token/metadata.js index 7c28a414d..e350efd9f 100644 --- a/near-contract-standards/lib/non_fungible_token/metadata.js +++ b/near-contract-standards/lib/non_fungible_token/metadata.js @@ -7,10 +7,10 @@ export class NFTContractMetadata { this.spec = NFT_METADATA_SPEC; this.name = ""; this.symbol = ""; - this.icon = undefined; - this.base_uri = undefined; - this.reference = undefined; - this.reference_hash = undefined; + this.icon = null; + this.base_uri = null; + this.reference = null; + this.reference_hash = null; } init(spec, name, symbol, icon, base_uri, reference, reference_hash) { this.spec = spec; @@ -23,8 +23,8 @@ export class NFTContractMetadata { } assert_valid() { assert(this.spec == NFT_METADATA_SPEC, "Spec is not NFT metadata"); - assert((this.reference !== undefined) == (this.reference_hash !== undefined), "Reference and reference hash must be present"); - if (this.reference_hash !== undefined) { + assert((this.reference != null) == (this.reference_hash != null), "Reference and reference hash must be present"); + if (this.reference_hash != null) { assert(this.reference_hash.length == 32, "Hash has to be 32 bytes"); } } @@ -63,12 +63,12 @@ export class TokenMetadata { this.reference_hash = reference_hash; } assert_valid() { - assert((this.media !== undefined) == (this.media_hash !== undefined), "Media and media hash must be present"); - if (this.media_hash !== undefined) { + assert((this.media != null) == (this.media_hash != null), "Media and media hash must be present"); + if (this.media_hash != null) { assert(this.media_hash.length == 32, "Media hash has to be 32 bytes"); } - assert((this.reference !== undefined) == (this.reference_hash !== undefined), "Reference and reference hash must be present"); - if (this.reference_hash !== undefined) { + assert((this.reference != null) == (this.reference_hash != null), "Reference and reference hash must be present"); + if (this.reference_hash != null) { assert(this.reference_hash.length == 32, "Reference hash has to be 32 bytes"); } } diff --git a/near-contract-standards/lib/non_fungible_token/utils.d.ts b/near-contract-standards/lib/non_fungible_token/utils.d.ts index d787dc4c0..657e90549 100644 --- a/near-contract-standards/lib/non_fungible_token/utils.d.ts +++ b/near-contract-standards/lib/non_fungible_token/utils.d.ts @@ -1,9 +1,9 @@ -import { Bytes, AccountId } from "near-sdk-js"; +import { AccountId } from "near-sdk-js"; export declare function refund_storage_deposit(account_id: AccountId, storage_released: number): void; export declare function refund_deposit_to_account(storage_used: bigint, account_id: AccountId): void; /** Assumes that the precedecessor will be refunded */ export declare function refund_deposit(storage_used: bigint): void; -export declare function hash_account_id(account_id: AccountId): Bytes; +export declare function hash_account_id(account_id: AccountId): Uint8Array; /** Assert that at least 1 yoctoNEAR was attached. */ export declare function assert_at_least_one_yocto(): void; /** Assert that exactly 1 yoctoNEAR was attached */ diff --git a/near-contract-standards/lib/non_fungible_token/utils.js b/near-contract-standards/lib/non_fungible_token/utils.js index 68931c013..a4a2ef0f7 100644 --- a/near-contract-standards/lib/non_fungible_token/utils.js +++ b/near-contract-standards/lib/non_fungible_token/utils.js @@ -1,4 +1,4 @@ -import { near, assert } from "near-sdk-js"; +import { near, assert, bytes } from "near-sdk-js"; export function refund_storage_deposit(account_id, storage_released) { const promise_id = near.promiseBatchCreate(account_id); near.promiseBatchActionTransfer(promise_id, BigInt(storage_released) * near.storageByteCost()); @@ -20,7 +20,7 @@ export function refund_deposit(storage_used) { refund_deposit_to_account(storage_used, near.predecessorAccountId()); } export function hash_account_id(account_id) { - return near.sha256(account_id); + return near.sha256(bytes(account_id)); } /** Assert that at least 1 yoctoNEAR was attached. */ export function assert_at_least_one_yocto() { diff --git a/near-contract-standards/src/non_fungible_token/impl.ts b/near-contract-standards/src/non_fungible_token/impl.ts index 47c2dc58e..300e069bf 100644 --- a/near-contract-standards/src/non_fungible_token/impl.ts +++ b/near-contract-standards/src/non_fungible_token/impl.ts @@ -2,13 +2,14 @@ import { AccountId, UnorderedMap, LookupMap, - Bytes, near, UnorderedSet, assert, NearPromise, bytes, serialize, + str, + concat, } from "near-sdk-js"; import { TokenMetadata } from "./metadata"; import { @@ -214,7 +215,7 @@ export class NonFungibleToken if (msg) { return NearPromise.new(account_id).functionCall( "nft_on_approve", - bytes(serialize({ token_id, owner_id, approval_id, msg })), + serialize({ token_id, owner_id, approval_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_APPROVE ); @@ -331,8 +332,8 @@ export class NonFungibleToken let next_approval_id_by_id: Option>; if (approval_prefix) { const prefix = approval_prefix.into_storage_key(); - approvals_by_id = new LookupMap(prefix); - next_approval_id_by_id = new LookupMap(prefix + "n"); + approvals_by_id = new LookupMap(str(prefix)); + next_approval_id_by_id = new LookupMap(str(prefix) + "n"); } else { approvals_by_id = null; next_approval_id_by_id = null; @@ -340,12 +341,14 @@ export class NonFungibleToken this.owner_id = owner_id; this.extra_storage_in_bytes_per_token = 0n; - this.owner_by_id = new UnorderedMap(owner_by_id_prefix.into_storage_key()); + this.owner_by_id = new UnorderedMap( + str(owner_by_id_prefix.into_storage_key()) + ); this.token_metadata_by_id = token_metadata_prefix - ? new LookupMap(token_metadata_prefix.into_storage_key()) + ? new LookupMap(str(token_metadata_prefix.into_storage_key())) : null; this.tokens_per_owner = enumeration_prefix - ? new LookupMap(enumeration_prefix.into_storage_key()) + ? new LookupMap(str(enumeration_prefix.into_storage_key())) : null; this.approvals_by_id = approvals_by_id; this.next_approval_id_by_id = next_approval_id_by_id; @@ -404,7 +407,11 @@ export class NonFungibleToken } if (this.tokens_per_owner) { const u = new UnorderedSet( - new TokensPerOwner(near.sha256(tmp_owner_id)).into_storage_key() + str( + new TokensPerOwner( + near.sha256(bytes(tmp_owner_id)) + ).into_storage_key() + ) ); u.set(tmp_token_id); this.tokens_per_owner.set(tmp_owner_id, u); @@ -467,7 +474,7 @@ export class NonFungibleToken }); if (receiver_tokens_set === null) { receiver_tokens_set = new UnorderedSet( - new TokensPerOwner(near.sha256(to)).into_storage_key() + str(new TokensPerOwner(near.sha256(bytes(to))).into_storage_key()) ); } receiver_tokens_set.set(token_id); @@ -577,7 +584,9 @@ export class NonFungibleToken }); if (token_ids === null) { token_ids = new UnorderedSet( - new TokensPerOwner(near.sha256(owner_id)).into_storage_key() + str( + new TokensPerOwner(near.sha256(bytes(owner_id))).into_storage_key() + ) ); } token_ids.set(token_id); @@ -686,9 +695,9 @@ export class NonFungibleToken approved_account_ids?: { [approvals: AccountId]: bigint }; }): boolean { let must_revert = false; - let p: Bytes; + let p: string; try { - p = near.promiseResult(0); + p = str(near.promiseResult(0)); } catch (e) { if (e.message.includes("Not Ready")) { throw new Error(); @@ -698,7 +707,7 @@ export class NonFungibleToken } if (!must_revert) { try { - const yes_or_no = JSON.parse(p as Bytes); + const yes_or_no = JSON.parse(p); if (typeof yes_or_no == "boolean") { must_revert = yes_or_no; } else { @@ -756,17 +765,17 @@ export class NonFungibleToken export type StorageKey = TokensPerOwner | TokenPerOwnerInner; export class TokensPerOwner implements IntoStorageKey { - constructor(public account_hash: Bytes) {} + constructor(public account_hash: Uint8Array) {} - into_storage_key(): Bytes { - return "\x00" + this.account_hash; + into_storage_key(): Uint8Array { + return concat(bytes("\x00"), this.account_hash); } } export class TokenPerOwnerInner implements IntoStorageKey { - constructor(public account_id_hash: Bytes) {} + constructor(public account_id_hash: Uint8Array) {} - into_storage_key(): Bytes { - return "\x01" + this.account_id_hash; + into_storage_key(): Uint8Array { + return concat(bytes("\x01"), this.account_id_hash); } } diff --git a/near-contract-standards/src/non_fungible_token/metadata.ts b/near-contract-standards/src/non_fungible_token/metadata.ts index ce220a551..208591d67 100644 --- a/near-contract-standards/src/non_fungible_token/metadata.ts +++ b/near-contract-standards/src/non_fungible_token/metadata.ts @@ -1,4 +1,4 @@ -import { assert, Bytes } from "near-sdk-js"; +import { assert } from "near-sdk-js"; import { Option } from "./utils"; /** This spec can be treated like a version of the standard. */ @@ -12,7 +12,7 @@ export class NFTContractMetadata { public icon: Option; // Data URL public base_uri: Option; // Centralized gateway known to have reliable access to decentralized storage assets referenced by `reference` or `media` URLs public reference: Option; // URL to a JSON file with more info - public reference_hash: Option; // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + public reference_hash: Option; // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. constructor() { this.spec = NFT_METADATA_SPEC; @@ -31,7 +31,7 @@ export class NFTContractMetadata { icon: Option, base_uri: Option, reference: Option, - reference_hash: Option + reference_hash: Option ) { this.spec = spec; this.name = name; @@ -66,7 +66,7 @@ export class TokenMetadata { public title: Option, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" public description: Option, // free-form description public media: Option, // URL to associated media, preferably to decentralized, content-addressed storage - public media_hash: Option, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + public media_hash: Option, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. public copies: Option, // number of copies of this set of metadata in existence when token was minted. public issued_at: Option, // ISO 8601 datetime when token was issued or minted public expires_at: Option, // ISO 8601 datetime when token expires @@ -74,7 +74,7 @@ export class TokenMetadata { public updated_at: Option, // ISO 8601 datetime when token was last updated public extra: Option, // anything extra the NFT wants to store on-chain. Can be stringified JSON. public reference: Option, // URL to an off-chain JSON file with more info. - public reference_hash: Option // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + public reference_hash: Option // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. ) {} assert_valid() { diff --git a/near-contract-standards/src/non_fungible_token/utils.ts b/near-contract-standards/src/non_fungible_token/utils.ts index 60d9562ad..9dc60a1fa 100644 --- a/near-contract-standards/src/non_fungible_token/utils.ts +++ b/near-contract-standards/src/non_fungible_token/utils.ts @@ -1,4 +1,4 @@ -import { near, assert, Bytes, AccountId } from "near-sdk-js"; +import { near, assert, AccountId, bytes } from "near-sdk-js"; export function refund_storage_deposit( account_id: AccountId, @@ -37,8 +37,8 @@ export function refund_deposit(storage_used: bigint): void { refund_deposit_to_account(storage_used, near.predecessorAccountId()); } -export function hash_account_id(account_id: AccountId): Bytes { - return near.sha256(account_id); +export function hash_account_id(account_id: AccountId): Uint8Array { + return near.sha256(bytes(account_id)); } /** Assert that at least 1 yoctoNEAR was attached. */ @@ -60,5 +60,5 @@ export function assert_one_yocto(): void { export type Option = T | null; export interface IntoStorageKey { - into_storage_key(): Bytes; + into_storage_key(): Uint8Array; } From 0d734ac6502f6925d42d48188899a845327e7435 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 8 Dec 2022 17:12:13 +0800 Subject: [PATCH 20/24] remove unused file --- .../lib/non_fungible_token/metadata.d.ts | 50 - yarn-error.log | 935 ------------------ 2 files changed, 985 deletions(-) delete mode 100644 near-contract-standards/lib/non_fungible_token/metadata.d.ts delete mode 100644 yarn-error.log diff --git a/near-contract-standards/lib/non_fungible_token/metadata.d.ts b/near-contract-standards/lib/non_fungible_token/metadata.d.ts deleted file mode 100644 index 6fd6cccef..000000000 --- a/near-contract-standards/lib/non_fungible_token/metadata.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Option } from "./utils"; -/** This spec can be treated like a version of the standard. */ -export declare const NFT_METADATA_SPEC = "nft-1.0.0"; -/** Metadata for the NFT contract itself. */ -export declare class NFTContractMetadata { - spec: string; - name: string; - symbol: string; - icon: Option; - base_uri: Option; - reference: Option; - reference_hash: Option; - constructor(); - init(spec: string, name: string, symbol: string, icon: Option, base_uri: Option, reference: Option, reference_hash: Option): void; - assert_valid(): void; - static reconstruct(data: NFTContractMetadata): NFTContractMetadata; -} -/** Metadata on the individual token level. */ -export declare class TokenMetadata { - title: Option; - description: Option; - media: Option; - media_hash: Option; - copies: Option; - issued_at: Option; - expires_at: Option; - starts_at: Option; - updated_at: Option; - extra: Option; - reference: Option; - reference_hash: Option; - constructor(title: Option, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - description: Option, // free-form description - media: Option, // URL to associated media, preferably to decentralized, content-addressed storage - media_hash: Option, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - copies: Option, // number of copies of this set of metadata in existence when token was minted. - issued_at: Option, // ISO 8601 datetime when token was issued or minted - expires_at: Option, // ISO 8601 datetime when token expires - starts_at: Option, // ISO 8601 datetime when token starts being valid - updated_at: Option, // ISO 8601 datetime when token was last updated - extra: Option, // anything extra the NFT wants to store on-chain. Can be stringified JSON. - reference: Option, // URL to an off-chain JSON file with more info. - reference_hash: Option); - assert_valid(): void; - static reconstruct(data: TokenMetadata): TokenMetadata; -} -/** Offers details on the contract-level metadata. */ -export interface NonFungibleTokenMetadataProvider { - nft_metadata(): NFTContractMetadata; -} diff --git a/yarn-error.log b/yarn-error.log deleted file mode 100644 index 315ead0bc..000000000 --- a/yarn-error.log +++ /dev/null @@ -1,935 +0,0 @@ -Arguments: - /home/bo/.nvm/versions/node/v16.14.0/bin/node /home/bo/.nvm/versions/node/v16.14.0/bin/yarn add @babel/preset-typescript: - -PATH: - /home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/.nvm/versions/node/v16.14.0/bin:/home/bo/.opam/4.07.1/bin:/home/bo/.cargo/bin:/home/bo/.nix-profile/bin:/home/bo/.local/bin:/home/bo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bo/.local/share/coursier/bin:/home/bo/Android/Sdk/tools/bin:/home/bo/Android/Sdk/platform-tools:/home/bo/Android/Sdk/emulator:/home/bo/Downloads/pkg/zig-linux-x86_64-0.8.1:/home/bo/Downloads/src/binaryen/bin:/home/bo/Downloads/src/wabt/bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin - -Yarn version: - 1.22.17 - -Node version: - 16.14.0 - -Platform: - linux x64 - -Trace: - Error: https://registry.yarnpkg.com/@babel%2fpreset-typescript:: Not found - at Request.params.callback [as _callback] (/home/bo/.nvm/versions/node/v16.14.0/lib/node_modules/yarn/lib/cli.js:67029:18) - at Request.self.callback (/home/bo/.nvm/versions/node/v16.14.0/lib/node_modules/yarn/lib/cli.js:140883:22) - at Request.emit (node:events:520:28) - at Request. (/home/bo/.nvm/versions/node/v16.14.0/lib/node_modules/yarn/lib/cli.js:141855:10) - at Request.emit (node:events:520:28) - at IncomingMessage. (/home/bo/.nvm/versions/node/v16.14.0/lib/node_modules/yarn/lib/cli.js:141777:12) - at Object.onceWrapper (node:events:639:28) - at IncomingMessage.emit (node:events:532:35) - at endReadableNT (node:internal/streams/readable:1346:12) - at processTicksAndRejections (node:internal/process/task_queues:83:21) - -npm manifest: - { - "name": "near-sdk-js", - "version": "0.3.0", - "description": "High Level JavaScript SDK for building smart contracts on NEAR", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "type": "module", - "repository": { - "type": "git", - "url": "git+https://github.com/near/near-sdk-js.git" - }, - "homepage": "https://github.com/near/near-sdk-js", - "keywords": [ - "JS", - "JavaScript", - "NEAR", - "SDK", - "contract", - "smart", - "smart-contract" - ], - "license": "(MIT AND Apache-2.0)", - "scripts": { - "build": "tsc -p ./tsconfig.json", - "pretest": "yarn build", - "test": "yarn test:standalone && yarn test:enclaved", - "test:standalone": "test:standalone:unit && test:standalone:examples", - "test:standalone:unit": "cd tests && yarn rebuild && yarn test && cd ..", - "test:standalone:examples": "cd examples && yarn && yarn rebuild && yarn test && cd ..", - "test:enclaved": "test:enclaved:unit && test:enclaved:examples", - "test:enclaved:unit": "cd jsvm/tests && yarn rebuild && yarn test && cd ../..", - "test:enclaved:examples": "cd jsvm/examples && yarn && yarn rebuild && yarn test && cd ../.." - }, - "bin": { - "near-sdk": "cli/cli.js" - }, - "author": "Near Inc ", - "dependencies": { - "@babel/core": "^7.17.5", - "@babel/plugin-proposal-decorators": "^7.17.2", - "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-commonjs": "^21.0.1", - "@rollup/plugin-node-resolve": "^13.1.1", - "rollup": "^2.61.1", - "rollup-plugin-sourcemaps": "^0.6.3", - "yargs": "^17.5.1" - }, - "files": [ - "cli", - "jsvm/build/jsvm.wasm", - "scripts", - "lib" - ], - "devDependencies": { - "@rollup/plugin-typescript": "^8.3.2", - "@types/node": "^17.0.38", - "@types/rollup": "^0.54.0", - "typescript": "^4.7.2" - } - } - -yarn manifest: - No manifest - -Lockfile: - # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. - # yarn lockfile v1 - - - "@ampproject/remapping@^2.1.0": - version "2.2.0" - resolved "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz" - integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== - dependencies: - "@jridgewell/gen-mapping" "^0.1.0" - "@jridgewell/trace-mapping" "^0.3.9" - - "@babel/code-frame@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - - "@babel/compat-data@^7.17.10": - version "7.17.10" - resolved "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.10.tgz" - integrity sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw== - - "@babel/core@^7.17.5": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/core/-/core-7.17.12.tgz" - integrity sha512-44ODe6O1IVz9s2oJE3rZ4trNNKTX9O7KpQpfAP4t8QII/zwrVRHL7i2pxhqtcY7tqMLrrKfMlBKnm1QlrRFs5w== - dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.12" - "@babel/helper-compilation-targets" "^7.17.10" - "@babel/helper-module-transforms" "^7.17.12" - "@babel/helpers" "^7.17.9" - "@babel/parser" "^7.17.12" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.12" - "@babel/types" "^7.17.12" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.1" - semver "^6.3.0" - - "@babel/generator@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.17.12.tgz" - integrity sha512-V49KtZiiiLjH/CnIW6OjJdrenrGoyh6AmKQ3k2AZFKozC1h846Q4NYlZ5nqAigPDUXfGzC88+LOUuG8yKd2kCw== - dependencies: - "@babel/types" "^7.17.12" - "@jridgewell/gen-mapping" "^0.3.0" - jsesc "^2.5.1" - - "@babel/helper-annotate-as-pure@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz" - integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-compilation-targets@^7.17.10": - version "7.17.10" - resolved "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.10.tgz" - integrity sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ== - dependencies: - "@babel/compat-data" "^7.17.10" - "@babel/helper-validator-option" "^7.16.7" - browserslist "^4.20.2" - semver "^6.3.0" - - "@babel/helper-create-class-features-plugin@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.12.tgz" - integrity sha512-sZoOeUTkFJMyhqCei2+Z+wtH/BehW8NVKQt7IRUQlRiOARuXymJYfN/FCcI8CvVbR0XVyDM6eLFOlR7YtiXnew== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.7" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.17.9" - "@babel/helper-member-expression-to-functions" "^7.17.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/helper-replace-supers" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - - "@babel/helper-environment-visitor@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz" - integrity sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-function-name@^7.17.9": - version "7.17.9" - resolved "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz" - integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== - dependencies: - "@babel/template" "^7.16.7" - "@babel/types" "^7.17.0" - - "@babel/helper-hoist-variables@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz" - integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-member-expression-to-functions@^7.16.7", "@babel/helper-member-expression-to-functions@^7.17.7": - version "7.17.7" - resolved "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz" - integrity sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw== - dependencies: - "@babel/types" "^7.17.0" - - "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz" - integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-module-transforms@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.12.tgz" - integrity sha512-t5s2BeSWIghhFRPh9XMn6EIGmvn8Lmw5RVASJzkIx1mSemubQQBNIZiQD7WzaFmaHIrjAec4x8z9Yx8SjJ1/LA== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/helper-validator-identifier" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.12" - "@babel/types" "^7.17.12" - - "@babel/helper-optimise-call-expression@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz" - integrity sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-plugin-utils@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.17.12.tgz" - integrity sha512-JDkf04mqtN3y4iAbO1hv9U2ARpPyPL1zqyWs/2WG1pgSq9llHFjStX5jdxb84himgJm+8Ng+x0oiWF/nw/XQKA== - - "@babel/helper-replace-supers@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz" - integrity sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-member-expression-to-functions" "^7.16.7" - "@babel/helper-optimise-call-expression" "^7.16.7" - "@babel/traverse" "^7.16.7" - "@babel/types" "^7.16.7" - - "@babel/helper-simple-access@^7.17.7": - version "7.17.7" - resolved "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz" - integrity sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA== - dependencies: - "@babel/types" "^7.17.0" - - "@babel/helper-split-export-declaration@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz" - integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== - dependencies: - "@babel/types" "^7.16.7" - - "@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - - "@babel/helper-validator-option@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz" - integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== - - "@babel/helpers@^7.17.9": - version "7.17.9" - resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.9.tgz" - integrity sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q== - dependencies: - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.9" - "@babel/types" "^7.17.0" - - "@babel/highlight@^7.16.7": - version "7.17.9" - resolved "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.9.tgz" - integrity sha512-J9PfEKCbFIv2X5bjTMiZu6Vf341N05QIY+d6FvVKynkG1S7G0j3I0QoRtWIrXhZ+/Nlb5Q0MzqL7TokEJ5BNHg== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - - "@babel/parser@^7.16.7", "@babel/parser@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.17.12.tgz" - integrity sha512-FLzHmN9V3AJIrWfOpvRlZCeVg/WLdicSnTMsLur6uDj9TT8ymUlG9XxURdW/XvuygK+2CW0poOJABdA4m/YKxA== - - "@babel/plugin-proposal-decorators@^7.17.2": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.17.12.tgz" - integrity sha512-gL0qSSeIk/VRfTDgtQg/EtejENssN/r3p5gJsPie1UacwiHibprpr19Z0pcK3XKuqQvjGVxsQ37Tl1MGfXzonA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.17.12" - "@babel/helper-plugin-utils" "^7.17.12" - "@babel/helper-replace-supers" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/plugin-syntax-decorators" "^7.17.12" - charcodes "^0.2.0" - - "@babel/plugin-syntax-decorators@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.17.12.tgz" - integrity sha512-D1Hz0qtGTza8K2xGyEdVNCYLdVHukAcbQr4K3/s6r/esadyEriZovpJimQOpu8ju4/jV8dW/1xdaE0UpDroidw== - dependencies: - "@babel/helper-plugin-utils" "^7.17.12" - - "@babel/template@^7.16.7": - version "7.16.7" - resolved "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz" - integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/parser" "^7.16.7" - "@babel/types" "^7.16.7" - - "@babel/traverse@^7.16.7", "@babel/traverse@^7.17.12", "@babel/traverse@^7.17.9": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.12.tgz" - integrity sha512-zULPs+TbCvOkIFd4FrG53xrpxvCBwLIgo6tO0tJorY7YV2IWFxUfS/lXDJbGgfyYt9ery/Gxj2niwttNnB0gIw== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.12" - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.17.9" - "@babel/helper-hoist-variables" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/parser" "^7.17.12" - "@babel/types" "^7.17.12" - debug "^4.1.0" - globals "^11.1.0" - - "@babel/types@^7.16.7", "@babel/types@^7.17.0", "@babel/types@^7.17.12": - version "7.17.12" - resolved "https://registry.npmjs.org/@babel/types/-/types-7.17.12.tgz" - integrity sha512-rH8i29wcZ6x9xjzI5ILHL/yZkbQnCERdHlogKuIb4PUr7do4iT8DPekrTbBLWTnRQm6U0GYABbTMSzijmEqlAg== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - to-fast-properties "^2.0.0" - - "@jridgewell/gen-mapping@^0.1.0": - version "0.1.1" - resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz" - integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== - dependencies: - "@jridgewell/set-array" "^1.0.0" - "@jridgewell/sourcemap-codec" "^1.4.10" - - "@jridgewell/gen-mapping@^0.3.0": - version "0.3.1" - resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz" - integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg== - dependencies: - "@jridgewell/set-array" "^1.0.0" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - - "@jridgewell/resolve-uri@^3.0.3": - version "3.0.7" - resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz" - integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== - - "@jridgewell/set-array@^1.0.0": - version "1.1.1" - resolved "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.1.tgz" - integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== - - "@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.13" - resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz" - integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== - - "@jridgewell/trace-mapping@^0.3.9": - version "0.3.10" - resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.10.tgz" - integrity sha512-Q0YbBd6OTsXm8Y21+YUSDXupHnodNC2M4O18jtd3iwJ3+vMZNdKGols0a9G6JOK0dcJ3IdUUHoh908ZI6qhk8Q== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - - "@rollup/plugin-babel@^5.3.1": - version "5.3.1" - resolved "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz" - integrity sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q== - dependencies: - "@babel/helper-module-imports" "^7.10.4" - "@rollup/pluginutils" "^3.1.0" - - "@rollup/plugin-commonjs@^21.0.1": - version "21.1.0" - resolved "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz" - integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA== - dependencies: - "@rollup/pluginutils" "^3.1.0" - commondir "^1.0.1" - estree-walker "^2.0.1" - glob "^7.1.6" - is-reference "^1.2.1" - magic-string "^0.25.7" - resolve "^1.17.0" - - "@rollup/plugin-node-resolve@^13.1.1": - version "13.3.0" - resolved "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz" - integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - deepmerge "^4.2.2" - is-builtin-module "^3.1.0" - is-module "^1.0.0" - resolve "^1.19.0" - - "@rollup/plugin-typescript@^8.3.2": - version "8.3.3" - resolved "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.3.3.tgz#eee7edab9cfc064f1cfd16570492693cf1432215" - integrity sha512-55L9SyiYu3r/JtqdjhwcwaECXP7JeJ9h1Sg1VWRJKIutla2MdZQodTgcCNybXLMCnqpNLEhS2vGENww98L1npg== - dependencies: - "@rollup/pluginutils" "^3.1.0" - resolve "^1.17.0" - - "@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - - "@types/estree@*", "@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - - "@types/node@*": - version "17.0.34" - resolved "https://registry.npmjs.org/@types/node/-/node-17.0.34.tgz" - integrity sha512-XImEz7XwTvDBtzlTnm8YvMqGW/ErMWBsKZ+hMTvnDIjGCKxwK5Xpc+c/oQjOauwq8M4OS11hEkpjX8rrI/eEgA== - - "@types/node@^17.0.38": - version "17.0.45" - resolved "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz#2c0fafd78705e7a18b7906b5201a522719dc5190" - integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== - - "@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - - "@types/rollup@^0.54.0": - version "0.54.0" - resolved "https://registry.npmjs.org/@types/rollup/-/rollup-0.54.0.tgz#e3ab3a7b3c1bf92969602dd92a589de39f324a31" - integrity sha512-oeYztLHhQ98jnr+u2cs1c3tHOGtpzrm9DJlIdEjznwoXWidUbrI+X6ib7zCkPIbB7eJ7VbbKNQ5n/bPnSg6Naw== - dependencies: - rollup "*" - - ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - - ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - - ansi-styles@^4.0.0: - version "4.3.0" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - - atob@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== - - balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - - brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - - browserslist@^4.20.2: - version "4.20.3" - resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz" - integrity sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg== - dependencies: - caniuse-lite "^1.0.30001332" - electron-to-chromium "^1.4.118" - escalade "^3.1.1" - node-releases "^2.0.3" - picocolors "^1.0.0" - - builtin-modules@^3.0.0: - version "3.3.0" - resolved "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz" - integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== - - caniuse-lite@^1.0.30001332: - version "1.0.30001339" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001339.tgz" - integrity sha512-Es8PiVqCe+uXdms0Gu5xP5PF2bxLR7OBp3wUzUnuO7OHzhOfCyg3hdiGWVPVxhiuniOzng+hTc1u3fEQ0TlkSQ== - - chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - - charcodes@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/charcodes/-/charcodes-0.2.0.tgz" - integrity sha512-Y4kiDb+AM4Ecy58YkuZrrSRJBDQdQ2L+NyS1vHHFtNtUjgutcZfx3yp1dAONI/oPaPmyGfCLx5CxL+zauIMyKQ== - - cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - - color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - - color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - - color-name@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - - color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - - commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= - - concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - - convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" - - debug@^4.1.0: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - - decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - - deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - - electron-to-chromium@^1.4.118: - version "1.4.137" - resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.137.tgz" - integrity sha512-0Rcpald12O11BUogJagX3HsCN3FE83DSqWjgXoHo5a72KUKMSfI39XBgJpgNNxS9fuGzytaFjE06kZkiVFy2qA== - - emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - - escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - - escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - - estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - - estree-walker@^2.0.1: - version "2.0.2" - resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz" - integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== - - fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - - fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - - function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - - gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - - get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - - glob@^7.1.6: - version "7.2.3" - resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - - globals@^11.1.0: - version "11.12.0" - resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - - has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= - - has@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - - inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - - inherits@2: - version "2.0.4" - resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - - is-builtin-module@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz" - integrity sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg== - dependencies: - builtin-modules "^3.0.0" - - is-core-module@^2.8.1: - version "2.9.0" - resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz" - integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== - dependencies: - has "^1.0.3" - - is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - - is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - - is-reference@^1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - - js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - - jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - - json5@^2.2.1: - version "2.2.1" - resolved "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== - - magic-string@^0.25.7: - version "0.25.9" - resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - - minimatch@^3.1.1: - version "3.1.2" - resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - - ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - - node-releases@^2.0.3: - version "2.0.4" - resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz" - integrity sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ== - - once@^1.3.0: - version "1.4.0" - resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - - path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - - path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - - picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - - picomatch@^2.2.2: - version "2.3.1" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - - require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= - - resolve@^1.17.0, resolve@^1.19.0: - version "1.22.0" - resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - - rollup-plugin-sourcemaps@^0.6.3: - version "0.6.3" - resolved "https://registry.npmjs.org/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz" - integrity sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw== - dependencies: - "@rollup/pluginutils" "^3.0.9" - source-map-resolve "^0.6.0" - - rollup@*: - version "2.75.7" - resolved "https://registry.npmjs.org/rollup/-/rollup-2.75.7.tgz#221ff11887ae271e37dcc649ba32ce1590aaa0b9" - integrity sha512-VSE1iy0eaAYNCxEXaleThdFXqZJ42qDBatAwrfnPlENEZ8erQ+0LYX4JXOLPceWfZpV1VtZwZ3dFCuOZiSyFtQ== - optionalDependencies: - fsevents "~2.3.2" - - rollup@^2.61.1: - version "2.73.0" - resolved "https://registry.npmjs.org/rollup/-/rollup-2.73.0.tgz" - integrity sha512-h/UngC3S4Zt28mB3g0+2YCMegT5yoftnQplwzPqGZcKvlld5e+kT/QRmJiL+qxGyZKOYpgirWGdLyEO1b0dpLQ== - optionalDependencies: - fsevents "~2.3.2" - - safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - - semver@^6.3.0: - version "6.3.0" - resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - - source-map-resolve@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz" - integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== - dependencies: - atob "^2.1.2" - decode-uri-component "^0.2.0" - - sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - - string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - - strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - - supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - - supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - - to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= - - typescript@^4.7.2: - version "4.7.4" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== - - wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - - wrappy@1: - version "1.0.2" - resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - - y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - - yargs-parser@^21.0.0: - version "21.0.1" - resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz" - integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== - - yargs@^17.5.1: - version "17.5.1" - resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz" - integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.0.0" From 2d4b3a56b9df41a41c602b67fec158badd643601 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 8 Dec 2022 17:59:41 +0800 Subject: [PATCH 21/24] fix test --- examples/src/counter-lowlevel.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/src/counter-lowlevel.js b/examples/src/counter-lowlevel.js index f01249ad2..84414839b 100644 --- a/examples/src/counter-lowlevel.js +++ b/examples/src/counter-lowlevel.js @@ -1,19 +1,19 @@ // This contract implements exact same functionality as counter.js, but only use low level APIs -import { near } from "near-sdk-js"; +import { near, bytes, str } from "near-sdk-js"; export function init() { let argsRaw = near.input(); - let args = JSON.parse(argsRaw || "{}"); + let args = JSON.parse(str(argsRaw) || "{}"); let initial = args.initial || 0; let count = initial; let state = JSON.stringify({ count }); - near.storageWrite("STATE", state); + near.storageWrite(bytes("STATE"), bytes(state)); } function deserialize() { - let state = near.storageRead("STATE"); + let state = near.storageRead(bytes("STATE")); if (state) { - return JSON.parse(state); + return JSON.parse(str(state)); } else { return { count: 0 }; } @@ -22,25 +22,25 @@ function deserialize() { export function getCount() { let state = deserialize(); let count = state.count; - near.valueReturn(JSON.stringify(count)); + near.valueReturn(bytes(JSON.stringify(count))); } export function increase() { let argsRaw = near.input(); - let args = JSON.parse(argsRaw || "{}"); + let args = JSON.parse(str(argsRaw) || "{}"); let n = args.n || 1; let state = deserialize(); state.count += n; near.log(`Counter increased to ${state.count}`); - near.storageWrite("STATE", JSON.stringify(state)); + near.storageWrite(bytes("STATE"), bytes(JSON.stringify(state))); } export function decrease() { let argsRaw = near.input(); - let args = JSON.parse(argsRaw || "{}"); + let args = JSON.parse(str(argsRaw) || "{}"); let n = args.n || 1; let state = deserialize(); state.count -= n; near.log(`Counter decreased to ${state.count}`); - near.storageWrite("STATE", JSON.stringify(state)); + near.storageWrite(bytes("STATE"), bytes(JSON.stringify(state))); } From 56a7a9969e36bcb0bbd1a2214c2036fec76fbb7e Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 12 Dec 2022 14:47:11 +0800 Subject: [PATCH 22/24] address Serhii comments --- .../__tests__/test-cross-contract-call.ava.js | 3 +- examples/yarn-error.log | 2269 ----------------- packages/near-sdk-js/src/api.ts | 1 + tests/__tests__/test_highlevel_promise.ava.js | 3 - tests/__tests__/test_promise_api.ava.js | 1 - tests/yarn-error.log | 2205 ---------------- 6 files changed, 2 insertions(+), 4480 deletions(-) delete mode 100644 examples/yarn-error.log delete mode 100644 tests/yarn-error.log diff --git a/examples/__tests__/test-cross-contract-call.ava.js b/examples/__tests__/test-cross-contract-call.ava.js index 65b1f2e6d..55308c930 100644 --- a/examples/__tests__/test-cross-contract-call.ava.js +++ b/examples/__tests__/test-cross-contract-call.ava.js @@ -52,13 +52,12 @@ test("Person can be set on-call if AVAILABLE", async (t) => { // Ali set her status as AVAILABLE await ali.call(statusMessage, "set_status", { message: "AVAILABLE" }); // Bob sets Ali on-call - let r = await bob.callRaw( + await bob.call( onCall, "set_person_on_call", { accountId: ali.accountId }, { gas: 120000000000000 } ); - console.log(JSON.stringify(r, null, 2)); // Check that Ali is on-call t.is(await onCall.view("person_on_call", {}), ali.accountId); diff --git a/examples/yarn-error.log b/examples/yarn-error.log deleted file mode 100644 index 3a61d9d1b..000000000 --- a/examples/yarn-error.log +++ /dev/null @@ -1,2269 +0,0 @@ -Arguments: - /home/bo/.nvm/versions/node/v16.14.0/bin/node /home/bo/.nvm/versions/node/v16.14.0/bin/yarn - -PATH: - /home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/.nvm/versions/node/v16.14.0/bin:/home/bo/.opam/4.07.1/bin:/home/bo/.cargo/bin:/home/bo/.nix-profile/bin:/home/bo/.local/bin:/home/bo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bo/.local/share/coursier/bin:/home/bo/Android/Sdk/tools/bin:/home/bo/Android/Sdk/platform-tools:/home/bo/Android/Sdk/emulator:/home/bo/Downloads/pkg/zig-linux-x86_64-0.8.1:/home/bo/Downloads/src/binaryen/bin:/home/bo/Downloads/src/wabt/bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin - -Yarn version: - 1.22.17 - -Node version: - 16.14.0 - -Platform: - linux x64 - -Trace: - Error: ENOSPC: no space left on device, copyfile '/home/bo/workspace/near-sdk-js/tests/node_modules/near-sdk-js/examples/node_modules/near-sdk-js/examples/node_modules/near-sdk-js/tests/node_modules/near-sdk-js/cli/qjsc/Linux-x86_64-qjsc' -> '/home/bo/.cache/yarn/v6/npm-near-sdk-js-0.4.0-2-bd181076-8ded-44a7-930f-c539e05f07ab-1659061750918/node_modules/near-sdk-js/tests/node_modules/near-sdk-js/examples/node_modules/near-sdk-js/examples/node_modules/near-sdk-js/tests/node_modules/near-sdk-js/cli/qjsc/Linux-x86_64-qjsc' - -npm manifest: - { - "name": "standalone-examples", - "version": "1.0.0", - "description": "Status message example with near-sdk-js", - "main": "index.js", - "type": "module", - "scripts": { - "build": "yarn build:clean-state && yarn build:counter && yarn build:counter-lowlevel && yarn build:counter-ts && yarn build:cross-contract-call && yarn build:fungible-token-lockable && yarn build:fungible-token && yarn build:non-fungible-token && yarn build:status-message-collections && yarn build:status-message", - "rebuild": "cd .. && yarn build && cd examples && rm -rf node_modules && rm -rf build && yarn && yarn build", - "build:status-message": "yarn near-sdk build src/status-message.js build/status-message.wasm", - "build:clean-state": "near-sdk build src/clean-state.js build/clean-state.wasm", - "build:counter": "near-sdk build src/counter.js build/counter.wasm", - "build:counter-lowlevel": "near-sdk build src/counter-lowlevel.js build/counter-lowlevel.wasm", - "build:counter-ts": "near-sdk build src/counter.ts build/counter-ts.wasm", - "build:cross-contract-call": "near-sdk build src/status-message.js build/status-message.wasm && near-sdk build src/cross-contract-call.js build/cross-contract-call.wasm", - "build:fungible-token-lockable": "near-sdk build src/fungible-token-lockable.js build/fungible-token-lockable.wasm", - "build:fungible-token": "near-sdk build src/fungible-token.js build/fungible-token.wasm", - "build:non-fungible-token": "near-sdk build src/non-fungible-token-receiver.js build/non-fungible-token-receiver.wasm && near-sdk build src/non-fungible-token.js build/non-fungible-token.wasm", - "build:status-message-collections": "near-sdk build src/status-message-collections.js build/status-message-collections.wasm", - "build:parking-lot": "near-sdk build src/parking-lot.ts build/parking-lot.wasm", - "test": "ava && yarn test:counter-lowlevel && yarn test:counter-ts", - "test:status-message": "ava __tests__/test-status-message.ava.js", - "test:clean-state": "ava __tests__/test-clean-state.ava.js", - "test:counter": "ava __tests__/test-counter.ava.js", - "test:counter-lowlevel": "COUNTER_LOWLEVEL=1 ava __tests__/test-counter.ava.js", - "test:counter-ts": "COUNTER_TS=1 ava __tests__/test-counter.ava.js", - "test:cross-contract-call": "ava __tests__/test-cross-contract-call.ava.js", - "test:fungible-token-lockable": "ava __tests__/test-fungible-token-lockable.ava.js", - "test:fungible-token": "ava __tests__/test-fungible-token.ava.js", - "test:non-fungible-token": "ava __tests__/test-non-fungible-token.ava.js", - "test:status-message-collections": "ava __tests__/test-status-message-collections.ava.js", - "test:parking-lot": "ava __tests__/test-parking-lot.ava.js" - }, - "author": "Near Inc ", - "license": "Apache-2.0", - "dependencies": { - "lodash-es": "^4.17.21", - "near-sdk-js": "file:../" - }, - "devDependencies": { - "ava": "^4.2.0", - "near-workspaces": "3.1.0", - "typescript": "^4.7.4" - } - } - -yarn manifest: - No manifest - -Lockfile: - # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. - # yarn lockfile v1 - - - "@ampproject/remapping@^2.1.0": - version "2.2.0" - resolved "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" - integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== - dependencies: - "@jridgewell/gen-mapping" "^0.1.0" - "@jridgewell/trace-mapping" "^0.3.9" - - "@babel/code-frame@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" - integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== - dependencies: - "@babel/highlight" "^7.18.6" - - "@babel/compat-data@^7.18.8": - version "7.18.8" - resolved "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.8.tgz#2483f565faca607b8535590e84e7de323f27764d" - integrity sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ== - - "@babel/core@^7.17.5": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/core/-/core-7.18.9.tgz#805461f967c77ff46c74ca0460ccf4fe933ddd59" - integrity sha512-1LIb1eL8APMy91/IMW+31ckrfBM4yCoLaVzoDhZUKSM4cu1L1nIidyxkCgzPAgrC5WEz36IPEr/eSeSF9pIn+g== - dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.18.9" - "@babel/helper-compilation-targets" "^7.18.9" - "@babel/helper-module-transforms" "^7.18.9" - "@babel/helpers" "^7.18.9" - "@babel/parser" "^7.18.9" - "@babel/template" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.1" - semver "^6.3.0" - - "@babel/generator@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.18.9.tgz#68337e9ea8044d6ddc690fb29acae39359cca0a5" - integrity sha512-wt5Naw6lJrL1/SGkipMiFxJjtyczUWTP38deiP1PO60HsBjDeKk08CGC3S8iVuvf0FmTdgKwU1KIXzSKL1G0Ug== - dependencies: - "@babel/types" "^7.18.9" - "@jridgewell/gen-mapping" "^0.3.2" - jsesc "^2.5.1" - - "@babel/helper-annotate-as-pure@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" - integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-compilation-targets@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz#69e64f57b524cde3e5ff6cc5a9f4a387ee5563bf" - integrity sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg== - dependencies: - "@babel/compat-data" "^7.18.8" - "@babel/helper-validator-option" "^7.18.6" - browserslist "^4.20.2" - semver "^6.3.0" - - "@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz#d802ee16a64a9e824fcbf0a2ffc92f19d58550ce" - integrity sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.18.9" - "@babel/helper-member-expression-to-functions" "^7.18.9" - "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/helper-replace-supers" "^7.18.9" - "@babel/helper-split-export-declaration" "^7.18.6" - - "@babel/helper-environment-visitor@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" - integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== - - "@babel/helper-function-name@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz#940e6084a55dee867d33b4e487da2676365e86b0" - integrity sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A== - dependencies: - "@babel/template" "^7.18.6" - "@babel/types" "^7.18.9" - - "@babel/helper-hoist-variables@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" - integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-member-expression-to-functions@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz#1531661e8375af843ad37ac692c132841e2fd815" - integrity sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg== - dependencies: - "@babel/types" "^7.18.9" - - "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" - integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-module-transforms@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz#5a1079c005135ed627442df31a42887e80fcb712" - integrity sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g== - dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-simple-access" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/helper-validator-identifier" "^7.18.6" - "@babel/template" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" - - "@babel/helper-optimise-call-expression@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" - integrity sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz#4b8aea3b069d8cb8a72cdfe28ddf5ceca695ef2f" - integrity sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w== - - "@babel/helper-replace-supers@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.18.9.tgz#1092e002feca980fbbb0bd4d51b74a65c6a500e6" - integrity sha512-dNsWibVI4lNT6HiuOIBr1oyxo40HvIVmbwPUm3XZ7wMh4k2WxrxTqZwSqw/eEmXDS9np0ey5M2bz9tBmO9c+YQ== - dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-member-expression-to-functions" "^7.18.9" - "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" - - "@babel/helper-simple-access@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz#d6d8f51f4ac2978068df934b569f08f29788c7ea" - integrity sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-split-export-declaration@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" - integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== - dependencies: - "@babel/types" "^7.18.6" - - "@babel/helper-validator-identifier@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" - integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== - - "@babel/helper-validator-option@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" - integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== - - "@babel/helpers@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz#4bef3b893f253a1eced04516824ede94dcfe7ff9" - integrity sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ== - dependencies: - "@babel/template" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" - - "@babel/highlight@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" - integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== - dependencies: - "@babel/helper-validator-identifier" "^7.18.6" - chalk "^2.0.0" - js-tokens "^4.0.0" - - "@babel/parser@^7.18.6", "@babel/parser@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.18.9.tgz#f2dde0c682ccc264a9a8595efd030a5cc8fd2539" - integrity sha512-9uJveS9eY9DJ0t64YbIBZICtJy8a5QrDEVdiLCG97fVLpDTpGX7t8mMSb6OWw6Lrnjqj4O8zwjELX3dhoMgiBg== - - "@babel/plugin-proposal-decorators@^7.17.2": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.18.9.tgz#d09d41ffc74af8499d2ac706ed0dbd5474711665" - integrity sha512-KD7zDNaD14CRpjQjVbV4EnH9lsKYlcpUrhZH37ei2IY+AlXrfAPy5pTmRUE4X6X1k8EsKXPraykxeaogqQvSGA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.18.9" - "@babel/helper-plugin-utils" "^7.18.9" - "@babel/helper-replace-supers" "^7.18.9" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/plugin-syntax-decorators" "^7.18.6" - - "@babel/plugin-syntax-decorators@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.18.6.tgz#2e45af22835d0b0f8665da2bfd4463649ce5dbc1" - integrity sha512-fqyLgjcxf/1yhyZ6A+yo1u9gJ7eleFQod2lkaUsF9DQ7sbbY3Ligym3L0+I2c0WmqNKDpoD9UTb1AKP3qRMOAQ== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - - "@babel/plugin-syntax-typescript@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz#1c09cd25795c7c2b8a4ba9ae49394576d4133285" - integrity sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - - "@babel/plugin-transform-typescript@^7.18.6": - version "7.18.8" - resolved "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.18.8.tgz#303feb7a920e650f2213ef37b36bbf327e6fa5a0" - integrity sha512-p2xM8HI83UObjsZGofMV/EdYjamsDm6MoN3hXPYIT0+gxIoopE+B7rPYKAxfrz9K9PK7JafTTjqYC6qipLExYA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-typescript" "^7.18.6" - - "@babel/preset-typescript@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399" - integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/helper-validator-option" "^7.18.6" - "@babel/plugin-transform-typescript" "^7.18.6" - - "@babel/template@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/template/-/template-7.18.6.tgz#1283f4993e00b929d6e2d3c72fdc9168a2977a31" - integrity sha512-JoDWzPe+wgBsTTgdnIma3iHNFC7YVJoPssVBDjiHfNlyt4YcunDtcDOUmfVDfCK5MfdsaIoX9PkijPhjH3nYUw== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/parser" "^7.18.6" - "@babel/types" "^7.18.6" - - "@babel/traverse@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.9.tgz#deeff3e8f1bad9786874cb2feda7a2d77a904f98" - integrity sha512-LcPAnujXGwBgv3/WHv01pHtb2tihcyW1XuL9wd7jqh1Z8AQkTd+QVjMrMijrln0T7ED3UXLIy36P9Ao7W75rYg== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.18.9" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.18.9" - "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.18.9" - "@babel/types" "^7.18.9" - debug "^4.1.0" - globals "^11.1.0" - - "@babel/types@^7.18.6", "@babel/types@^7.18.9": - version "7.18.9" - resolved "https://registry.npmjs.org/@babel/types/-/types-7.18.9.tgz#7148d64ba133d8d73a41b3172ac4b83a1452205f" - integrity sha512-WwMLAg2MvJmt/rKEVQBBhIVffMmnilX4oe0sRe7iPOHIGsqpruFHHdrfj4O1CMMtgMtCU4oPafZjDPCRgO57Wg== - dependencies: - "@babel/helper-validator-identifier" "^7.18.6" - to-fast-properties "^2.0.0" - - "@jridgewell/gen-mapping@^0.1.0": - version "0.1.1" - resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" - integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== - dependencies: - "@jridgewell/set-array" "^1.0.0" - "@jridgewell/sourcemap-codec" "^1.4.10" - - "@jridgewell/gen-mapping@^0.3.2": - version "0.3.2" - resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== - dependencies: - "@jridgewell/set-array" "^1.0.1" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" - - "@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - - "@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== - - "@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - - "@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - - "@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - - "@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - - "@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - - "@rollup/plugin-babel@^5.3.1": - version "5.3.1" - resolved "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" - integrity sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q== - dependencies: - "@babel/helper-module-imports" "^7.10.4" - "@rollup/pluginutils" "^3.1.0" - - "@rollup/plugin-commonjs@^21.0.1": - version "21.1.0" - resolved "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553" - integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA== - dependencies: - "@rollup/pluginutils" "^3.1.0" - commondir "^1.0.1" - estree-walker "^2.0.1" - glob "^7.1.6" - is-reference "^1.2.1" - magic-string "^0.25.7" - resolve "^1.17.0" - - "@rollup/plugin-node-resolve@^13.1.1": - version "13.3.0" - resolved "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz#da1c5c5ce8316cef96a2f823d111c1e4e498801c" - integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - deepmerge "^4.2.2" - is-builtin-module "^3.1.0" - is-module "^1.0.0" - resolve "^1.19.0" - - "@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - - "@sindresorhus/is@^4.0.0": - version "4.6.0" - resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz" - integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== - - "@szmarczak/http-timer@^4.0.5": - version "4.0.6" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz" - integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== - dependencies: - defer-to-connect "^2.0.0" - - "@types/cacheable-request@^6.0.1": - version "6.0.2" - resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz" - integrity sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "*" - "@types/node" "*" - "@types/responselike" "*" - - "@types/estree@*": - version "1.0.0" - resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" - integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== - - "@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - - "@types/http-cache-semantics@*": - version "4.0.1" - resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz" - integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== - - "@types/json-buffer@~3.0.0": - version "3.0.0" - resolved "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz" - integrity sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ== - - "@types/keyv@*": - version "3.1.4" - resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz" - integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== - dependencies: - "@types/node" "*" - - "@types/node@*": - version "18.0.0" - resolved "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz" - integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA== - - "@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - - "@types/responselike@*", "@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - - acorn-walk@^8.2.0: - version "8.2.0" - resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - - acorn@^8.7.1: - version "8.7.1" - resolved "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - - aggregate-error@^3.0.0: - version "3.1.0" - resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz" - integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== - dependencies: - clean-stack "^2.0.0" - indent-string "^4.0.0" - - aggregate-error@^4.0.0: - version "4.0.1" - resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-4.0.1.tgz" - integrity sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w== - dependencies: - clean-stack "^4.0.0" - indent-string "^5.0.0" - - ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - - ansi-regex@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz" - integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== - - ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - - ansi-styles@^4.0.0: - version "4.3.0" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - - ansi-styles@^6.0.0, ansi-styles@^6.1.0: - version "6.1.0" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz" - integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== - - anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - - argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - - array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz" - integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== - - array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - - arrgv@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/arrgv/-/arrgv-1.0.2.tgz" - integrity sha512-a4eg4yhp7mmruZDQFqVMlxNRFGi/i1r87pt8SDHy0/I8PqSXoUTlWZRdAZo0VXgvEARcujbtTk8kiZRi1uDGRw== - - arrify@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/arrify/-/arrify-3.0.0.tgz" - integrity sha512-tLkvA81vQG/XqE2mjDkGQHoOINtMHtysSnemrmoGe6PydDPMRbVugqyk4A6V/WDWEfm3l+0d8anA9r8cv/5Jaw== - - atob@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== - - ava@^4.2.0: - version "4.3.0" - resolved "https://registry.npmjs.org/ava/-/ava-4.3.0.tgz" - integrity sha512-Ap0u8rp8wOBN6CxshgxrPSe191e8g52RWGoXeDB57ubo4fyZyStfI6OxQi/bl0yxIDEOYHhCiGwihbzlMNJw3Q== - dependencies: - acorn "^8.7.1" - acorn-walk "^8.2.0" - ansi-styles "^6.1.0" - arrgv "^1.0.2" - arrify "^3.0.0" - callsites "^4.0.0" - cbor "^8.1.0" - chalk "^5.0.1" - chokidar "^3.5.3" - chunkd "^2.0.1" - ci-info "^3.3.1" - ci-parallel-vars "^1.0.1" - clean-yaml-object "^0.1.0" - cli-truncate "^3.1.0" - code-excerpt "^4.0.0" - common-path-prefix "^3.0.0" - concordance "^5.0.4" - currently-unhandled "^0.4.1" - debug "^4.3.4" - del "^6.1.1" - emittery "^0.11.0" - figures "^4.0.1" - globby "^13.1.1" - ignore-by-default "^2.1.0" - indent-string "^5.0.0" - is-error "^2.2.2" - is-plain-object "^5.0.0" - is-promise "^4.0.0" - matcher "^5.0.0" - mem "^9.0.2" - ms "^2.1.3" - p-event "^5.0.1" - p-map "^5.4.0" - picomatch "^2.3.1" - pkg-conf "^4.0.0" - plur "^5.1.0" - pretty-ms "^7.0.1" - resolve-cwd "^3.0.0" - slash "^3.0.0" - stack-utils "^2.0.5" - strip-ansi "^7.0.1" - supertap "^3.0.1" - temp-dir "^2.0.0" - write-file-atomic "^4.0.1" - yargs "^17.5.1" - - balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - - base-x@^3.0.2: - version "3.0.9" - resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - - base64url@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz" - integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== - - binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - - blueimp-md5@^2.10.0: - version "2.19.0" - resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz" - integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w== - - bn.js@5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - - bn.js@^5.2.0: - version "5.2.1" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== - - borsh@^0.5.0: - version "0.5.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.5.0.tgz" - integrity sha512-p9w/qGBeeFdUf2GPBPHdX5JQyez8K5VtoFN7PqSfmR+cVUMSmcwAKhP9n2aXoDSKbtS7xZlZt3MVnrJL7GdYhg== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - - borsh@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.6.0.tgz" - integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - - brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - - braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - - browserslist@^4.20.2: - version "4.21.2" - resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.21.2.tgz#59a400757465535954946a400b841ed37e2b4ecf" - integrity sha512-MonuOgAtUB46uP5CezYbRaYKBNt2LxP0yX+Pmj4LkcDFGkn9Cbpi83d9sCjwQDErXsIJSzY5oKGDbgOlF/LPAA== - dependencies: - caniuse-lite "^1.0.30001366" - electron-to-chromium "^1.4.188" - node-releases "^2.0.6" - update-browserslist-db "^1.0.4" - - bs58@^4.0.0, bs58@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz" - integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== - dependencies: - base-x "^3.0.2" - - builtin-modules@^3.0.0: - version "3.3.0" - resolved "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" - integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== - - cacheable-lookup@^5.0.3: - version "5.0.4" - resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz" - integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== - - cacheable-request@^7.0.2: - version "7.0.2" - resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz" - integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^6.0.1" - responselike "^2.0.0" - - callsites@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/callsites/-/callsites-4.0.0.tgz" - integrity sha512-y3jRROutgpKdz5vzEhWM34TidDU8vkJppF8dszITeb1PQmSqV3DTxyV8G/lyO/DNvtE1YTedehmw9MPZsCBHxQ== - - caniuse-lite@^1.0.30001366: - version "1.0.30001367" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001367.tgz#2b97fe472e8fa29c78c5970615d7cd2ee414108a" - integrity sha512-XDgbeOHfifWV3GEES2B8rtsrADx4Jf+juKX2SICJcaUhjYBO3bR96kvEIHa15VU6ohtOhBZuPGGYGbXMRn0NCw== - - capability@^0.2.5: - version "0.2.5" - resolved "https://registry.npmjs.org/capability/-/capability-0.2.5.tgz" - integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== - - cbor@^8.1.0: - version "8.1.0" - resolved "https://registry.npmjs.org/cbor/-/cbor-8.1.0.tgz" - integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== - dependencies: - nofilter "^3.1.0" - - chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - - chalk@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz" - integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== - - chokidar@^3.5.3: - version "3.5.3" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - - chownr@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" - integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== - - chunkd@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/chunkd/-/chunkd-2.0.1.tgz" - integrity sha512-7d58XsFmOq0j6el67Ug9mHf9ELUXsQXYJBkyxhH/k+6Ke0qXRnv0kbemx+Twc6fRJ07C49lcbdgm9FL1Ei/6SQ== - - ci-info@^3.3.1: - version "3.3.2" - resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz" - integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg== - - ci-parallel-vars@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/ci-parallel-vars/-/ci-parallel-vars-1.0.1.tgz" - integrity sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg== - - clean-stack@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz" - integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== - - clean-stack@^4.0.0: - version "4.2.0" - resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz" - integrity sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg== - dependencies: - escape-string-regexp "5.0.0" - - clean-yaml-object@^0.1.0: - version "0.1.0" - resolved "https://registry.npmjs.org/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz" - integrity sha512-3yONmlN9CSAkzNwnRCiJQ7Q2xK5mWuEfL3PuTZcAUzhObbXsfsnMptJzXwz93nc5zn9V9TwCVMmV7w4xsm43dw== - - cli-truncate@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz" - integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== - dependencies: - slice-ansi "^5.0.0" - string-width "^5.0.0" - - cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - - clone-response@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz" - integrity sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q== - dependencies: - mimic-response "^1.0.0" - - code-excerpt@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz" - integrity sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA== - dependencies: - convert-to-spaces "^2.0.1" - - color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - - color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - - color-name@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== - - color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - - common-path-prefix@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz" - integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w== - - commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== - - compress-brotli@^1.3.8: - version "1.3.8" - resolved "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz" - integrity sha512-lVcQsjhxhIXsuupfy9fmZUFtAIdBmXA7EGY6GBdgZ++qkM9zG4YFT8iU7FoBxzryNDMOpD1HIFHUSX4D87oqhQ== - dependencies: - "@types/json-buffer" "~3.0.0" - json-buffer "~3.0.1" - - concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - - concordance@^5.0.4: - version "5.0.4" - resolved "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz" - integrity sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw== - dependencies: - date-time "^3.1.0" - esutils "^2.0.3" - fast-diff "^1.2.0" - js-string-escape "^1.0.1" - lodash "^4.17.15" - md5-hex "^3.0.1" - semver "^7.3.2" - well-known-symbols "^2.0.0" - - convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" - - convert-to-spaces@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz" - integrity sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ== - - currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz" - integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== - dependencies: - array-find-index "^1.0.1" - - date-time@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz" - integrity sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg== - dependencies: - time-zone "^1.0.0" - - debug@^4.1.0, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - - decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og== - - decompress-response@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz" - integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== - dependencies: - mimic-response "^3.1.0" - - deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - - defer-to-connect@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz" - integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== - - del@^6.1.1: - version "6.1.1" - resolved "https://registry.npmjs.org/del/-/del-6.1.1.tgz" - integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg== - dependencies: - globby "^11.0.1" - graceful-fs "^4.2.4" - is-glob "^4.0.1" - is-path-cwd "^2.2.0" - is-path-inside "^3.0.2" - p-map "^4.0.0" - rimraf "^3.0.2" - slash "^3.0.0" - - depd@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - - depd@~1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - - dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - - eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - - electron-to-chromium@^1.4.188: - version "1.4.195" - resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.195.tgz#139b2d95a42a3f17df217589723a1deac71d1473" - integrity sha512-vefjEh0sk871xNmR5whJf9TEngX+KTKS3hOHpjoMpauKkwlGwtMz1H8IaIjAT/GNnX0TbGwAdmVoXCAzXf+PPg== - - emittery@^0.11.0: - version "0.11.0" - resolved "https://registry.npmjs.org/emittery/-/emittery-0.11.0.tgz" - integrity sha512-S/7tzL6v5i+4iJd627Nhv9cLFIo5weAIlGccqJFpnBoDB8U1TF2k5tez4J/QNuxyyhWuFqHg1L84Kd3m7iXg6g== - - emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - - emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - - end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - - error-polyfill@^0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/error-polyfill/-/error-polyfill-0.1.3.tgz" - integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== - dependencies: - capability "^0.2.5" - o3 "^1.0.3" - u3 "^0.1.1" - - escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - - escape-string-regexp@5.0.0, escape-string-regexp@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz" - integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== - - escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - - escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - - esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - - estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - - estree-walker@^2.0.1: - version "2.0.2" - resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" - integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== - - esutils@^2.0.3: - version "2.0.3" - resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - - fast-diff@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz" - integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== - - fast-glob@^3.2.11, fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - - fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" - - figures@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/figures/-/figures-4.0.1.tgz" - integrity sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w== - dependencies: - escape-string-regexp "^5.0.0" - is-unicode-supported "^1.2.0" - - fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - - find-up@^6.0.0: - version "6.3.0" - resolved "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz" - integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw== - dependencies: - locate-path "^7.1.0" - path-exists "^5.0.0" - - fs-extra@^10.0.0: - version "10.1.0" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz" - integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - - fs-minipass@^2.0.0: - version "2.1.0" - resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz" - integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== - dependencies: - minipass "^3.0.0" - - fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - - fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - - function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - - gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - - get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - - get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - - glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - - glob@^7.1.3, glob@^7.1.6: - version "7.2.3" - resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - - globals@^11.1.0: - version "11.12.0" - resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - - globby@^11.0.1: - version "11.1.0" - resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - - globby@^13.1.1: - version "13.1.2" - resolved "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz" - integrity sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ== - dependencies: - dir-glob "^3.0.1" - fast-glob "^3.2.11" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^4.0.0" - - got@^11.8.2: - version "11.8.5" - resolved "https://registry.npmjs.org/got/-/got-11.8.5.tgz" - integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ== - dependencies: - "@sindresorhus/is" "^4.0.0" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.2" - decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" - - graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: - version "4.2.10" - resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - - has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== - - has@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - - http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== - - http-errors@^1.7.2: - version "1.8.1" - resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - - http2-wrapper@^1.0.0-beta.5.2: - version "1.0.3" - resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz" - integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.0.0" - - ignore-by-default@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-2.1.0.tgz" - integrity sha512-yiWd4GVmJp0Q6ghmM2B/V3oZGRmjrKLXvHR3TE1nfoXsmoggllfZUQe74EN0fJdPFZu2NIvNdrMMLm3OsV7Ohw== - - ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - - imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" - integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== - - indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - - indent-string@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz" - integrity sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg== - - inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - - inherits@2, inherits@2.0.4: - version "2.0.4" - resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - - irregular-plurals@^3.3.0: - version "3.3.0" - resolved "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.3.0.tgz" - integrity sha512-MVBLKUTangM3EfRPFROhmWQQKRDsrgI83J8GS3jXy+OwYqiR2/aoWndYQ5416jLE3uaGgLH7ncme3X9y09gZ3g== - - is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - - is-builtin-module@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz#6fdb24313b1c03b75f8b9711c0feb8c30b903b00" - integrity sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg== - dependencies: - builtin-modules "^3.0.0" - - is-core-module@^2.9.0: - version "2.9.0" - resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz#e1c34429cd51c6dd9e09e0799e396e27b19a9c69" - integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== - dependencies: - has "^1.0.3" - - is-error@^2.2.2: - version "2.2.2" - resolved "https://registry.npmjs.org/is-error/-/is-error-2.2.2.tgz" - integrity sha512-IOQqts/aHWbiisY5DuPJQ0gcbvaLFCa7fBa9xoLfxBZvQ+ZI/Zh9xoI7Gk+G64N0FdK4AbibytHht2tWgpJWLg== - - is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - - is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - - is-fullwidth-code-point@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz" - integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== - - is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - - is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g== - - is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - - is-path-cwd@^2.2.0: - version "2.2.0" - resolved "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz" - integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== - - is-path-inside@^3.0.2: - version "3.0.3" - resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz" - integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== - - is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - - is-promise@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz" - integrity sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ== - - is-reference@^1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - - is-unicode-supported@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz" - integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ== - - js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - - js-string-escape@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz" - integrity sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg== - - js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - - js-yaml@^3.14.1: - version "3.14.1" - resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - - jsesc@^2.5.1: - version "2.5.2" - resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" - integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== - - json-buffer@3.0.1, json-buffer@~3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" - integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== - - json5@^2.2.1: - version "2.2.1" - resolved "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== - - jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - - keyv@^4.0.0: - version "4.3.2" - resolved "https://registry.npmjs.org/keyv/-/keyv-4.3.2.tgz" - integrity sha512-kn8WmodVBe12lmHpA6W8OY7SNh6wVR+Z+wZESF4iF5FCazaVXGWOtnbnvX0tMQ1bO+/TmOD9LziuYMvrIIs0xw== - dependencies: - compress-brotli "^1.3.8" - json-buffer "3.0.1" - - load-json-file@^7.0.0: - version "7.0.1" - resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-7.0.1.tgz" - integrity sha512-Gnxj3ev3mB5TkVBGad0JM6dmLiQL+o0t23JPBZ9sd+yvSLk05mFoqKBw5N8gbbkU4TNXyqCgIrl/VM17OgUIgQ== - - locate-path@^7.1.0: - version "7.1.1" - resolved "https://registry.npmjs.org/locate-path/-/locate-path-7.1.1.tgz" - integrity sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg== - dependencies: - p-locate "^6.0.0" - - lodash-es@^4.17.21: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz" - integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== - - lodash@^4.17.15: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - - lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - - lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - - magic-string@^0.25.7: - version "0.25.9" - resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - - map-age-cleaner@^0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - - matcher@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/matcher/-/matcher-5.0.0.tgz" - integrity sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw== - dependencies: - escape-string-regexp "^5.0.0" - - md5-hex@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz" - integrity sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw== - dependencies: - blueimp-md5 "^2.10.0" - - mem@^9.0.2: - version "9.0.2" - resolved "https://registry.npmjs.org/mem/-/mem-9.0.2.tgz" - integrity sha512-F2t4YIv9XQUBHt6AOJ0y7lSmP1+cY7Fm1DRh9GClTGzKST7UWLMx6ly9WZdLH/G/ppM5RL4MlQfRT71ri9t19A== - dependencies: - map-age-cleaner "^0.1.3" - mimic-fn "^4.0.0" - - merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - - micromatch@^4.0.4: - version "4.0.5" - resolved "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - - mimic-fn@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz" - integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== - - mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - - mimic-response@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz" - integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== - - minimatch@^3.1.1: - version "3.1.2" - resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - - minipass@^3.0.0: - version "3.3.4" - resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz" - integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw== - dependencies: - yallist "^4.0.0" - - minizlib@^2.1.1: - version "2.1.2" - resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" - integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== - dependencies: - minipass "^3.0.0" - yallist "^4.0.0" - - mkdirp@^1.0.3: - version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - - ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - - ms@^2.1.3: - version "2.1.3" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - - mustache@^4.0.0: - version "4.2.0" - resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" - integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== - - near-api-js@^0.44.1: - version "0.44.2" - resolved "https://registry.npmjs.org/near-api-js/-/near-api-js-0.44.2.tgz" - integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== - dependencies: - bn.js "5.2.0" - borsh "^0.6.0" - bs58 "^4.0.0" - depd "^2.0.0" - error-polyfill "^0.1.3" - http-errors "^1.7.2" - js-sha256 "^0.9.0" - mustache "^4.0.0" - node-fetch "^2.6.1" - text-encoding-utf-8 "^1.0.2" - tweetnacl "^1.0.1" - - near-sandbox@^0.0.12: - version "0.0.12" - resolved "https://registry.npmjs.org/near-sandbox/-/near-sandbox-0.0.12.tgz#b0e36c9458a437c5cb4e1218f715585f087904b1" - integrity sha512-NfMSbPYiSpSMijM3JoC1FuNJuc3Pop86OF+/01ahc8phWQbjT404rMR+UvvuCZQ6Qge8/MC76KjBUPg3d7mg1Q== - dependencies: - got "^11.8.2" - tar "^6.1.0" - - "near-sdk-js@file:..": - version "0.4.0-2" - dependencies: - "@babel/core" "^7.17.5" - "@babel/plugin-proposal-decorators" "^7.17.2" - "@babel/preset-typescript" "^7.18.6" - "@rollup/plugin-babel" "^5.3.1" - "@rollup/plugin-commonjs" "^21.0.1" - "@rollup/plugin-node-resolve" "^13.1.1" - rollup "^2.61.1" - rollup-plugin-sourcemaps "^0.6.3" - yargs "^17.5.1" - - near-units@^0.1.9: - version "0.1.9" - resolved "https://registry.npmjs.org/near-units/-/near-units-0.1.9.tgz" - integrity sha512-xiuBjpNsi+ywiu7P6iWRZdgFm7iCr/cfWlVO6+e5uaAqH4mE1rrurElyrL91llNDSnMwogd9XmlZOw5KbbHNsA== - dependencies: - bn.js "^5.2.0" - - near-workspaces@3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/near-workspaces/-/near-workspaces-3.1.0.tgz#d462ecb4bf2ae1cc33063995a1ef7db5e204910f" - integrity sha512-0f/S2YU0xNQ7UQwCW/pkqXspjeK0N+nYj3x7/sx+tUMsckNzahTLNww+3I0YBa/UtcMrCVsT5WDG8emvhdRxnQ== - dependencies: - base64url "^3.0.1" - bn.js "^5.2.0" - borsh "^0.5.0" - bs58 "^4.0.1" - callsites "^4.0.0" - fs-extra "^10.0.0" - js-sha256 "^0.9.0" - near-api-js "^0.44.1" - near-sandbox "^0.0.12" - near-units "^0.1.9" - node-port-check "^2.0.1" - promisify-child-process "^4.1.1" - pure-uuid "^1.6.2" - rimraf "^3.0.2" - temp-dir "^2.0.0" - - node-fetch@^2.6.1: - version "2.6.7" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - - node-port-check@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/node-port-check/-/node-port-check-2.0.1.tgz" - integrity sha512-PV1tj5OPbWwxvhPcChXxwCIKl/IfVEdPP4u/gQz2lao/VGoeIUXb/4U72KSHLZpTVBmgTnMm0me7yR0wUsIuPg== - - node-releases@^2.0.6: - version "2.0.6" - resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" - integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== - - nofilter@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz" - integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== - - normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - - normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== - - o3@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/o3/-/o3-1.0.3.tgz" - integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== - dependencies: - capability "^0.2.5" - - once@^1.3.0, once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - - p-cancelable@^2.0.0: - version "2.1.1" - resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz" - integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== - - p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz" - integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw== - - p-event@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/p-event/-/p-event-5.0.1.tgz" - integrity sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ== - dependencies: - p-timeout "^5.0.2" - - p-limit@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz" - integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ== - dependencies: - yocto-queue "^1.0.0" - - p-locate@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz" - integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw== - dependencies: - p-limit "^4.0.0" - - p-map@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz" - integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== - dependencies: - aggregate-error "^3.0.0" - - p-map@^5.4.0: - version "5.5.0" - resolved "https://registry.npmjs.org/p-map/-/p-map-5.5.0.tgz" - integrity sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg== - dependencies: - aggregate-error "^4.0.0" - - p-timeout@^5.0.2: - version "5.1.0" - resolved "https://registry.npmjs.org/p-timeout/-/p-timeout-5.1.0.tgz" - integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew== - - parse-ms@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz" - integrity sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA== - - path-exists@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz" - integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ== - - path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - - path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - - path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - - picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - - picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - - pkg-conf@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/pkg-conf/-/pkg-conf-4.0.0.tgz" - integrity sha512-7dmgi4UY4qk+4mj5Cd8v/GExPo0K+SlY+hulOSdfZ/T6jVH6//y7NtzZo5WrfhDBxuQ0jCa7fLZmNaNh7EWL/w== - dependencies: - find-up "^6.0.0" - load-json-file "^7.0.0" - - plur@^5.1.0: - version "5.1.0" - resolved "https://registry.npmjs.org/plur/-/plur-5.1.0.tgz" - integrity sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg== - dependencies: - irregular-plurals "^3.3.0" - - pretty-ms@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz" - integrity sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q== - dependencies: - parse-ms "^2.1.0" - - promisify-child-process@^4.1.1: - version "4.1.1" - resolved "https://registry.npmjs.org/promisify-child-process/-/promisify-child-process-4.1.1.tgz" - integrity sha512-/sRjHZwoXf1rJ+8s4oWjYjGRVKNK1DUnqfRC1Zek18pl0cN6k3yJ1cCbqd0tWNe4h0Gr+SY4vR42N33+T82WkA== - - pump@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - - pure-uuid@^1.6.2: - version "1.6.2" - resolved "https://registry.npmjs.org/pure-uuid/-/pure-uuid-1.6.2.tgz" - integrity sha512-WQ4xz74ApW6s0BToRuuyuMo9g0VHx1HljY0H2gPng+mqqz/K1yLj7sHZonZZQ2++WfHl/ZzruilWvuz+WtmxjQ== - - queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - - quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - - readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - - require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - - resolve-alpn@^1.0.0: - version "1.2.1" - resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" - integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== - - resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - - resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - - resolve@^1.17.0, resolve@^1.19.0: - version "1.22.1" - resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" - integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== - dependencies: - is-core-module "^2.9.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - - responselike@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz" - integrity sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw== - dependencies: - lowercase-keys "^2.0.0" - - reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - - rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - - rollup-plugin-sourcemaps@^0.6.3: - version "0.6.3" - resolved "https://registry.npmjs.org/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed" - integrity sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw== - dependencies: - "@rollup/pluginutils" "^3.0.9" - source-map-resolve "^0.6.0" - - rollup@^2.61.1: - version "2.77.0" - resolved "https://registry.npmjs.org/rollup/-/rollup-2.77.0.tgz#749eaa5ac09b6baa52acc076bc46613eddfd53f4" - integrity sha512-vL8xjY4yOQEw79DvyXLijhnhh+R/O9zpF/LEgkCebZFtb6ELeN9H3/2T0r8+mp+fFTBHZ5qGpOpW2ela2zRt3g== - optionalDependencies: - fsevents "~2.3.2" - - run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - - safe-buffer@^5.0.1: - version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - - safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - - semver@^6.3.0: - version "6.3.0" - resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - - semver@^7.3.2: - version "7.3.7" - resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - - serialize-error@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz" - integrity sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw== - dependencies: - type-fest "^0.13.1" - - setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - - signal-exit@^3.0.7: - version "3.0.7" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - - slash@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - - slash@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz" - integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== - - slice-ansi@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz" - integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== - dependencies: - ansi-styles "^6.0.0" - is-fullwidth-code-point "^4.0.0" - - source-map-resolve@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" - integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== - dependencies: - atob "^2.1.2" - decode-uri-component "^0.2.0" - - sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - - sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" - integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== - - stack-utils@^2.0.5: - version "2.0.5" - resolved "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== - dependencies: - escape-string-regexp "^2.0.0" - - "statuses@>= 1.5.0 < 2": - version "1.5.0" - resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - - string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - - string-width@^5.0.0: - version "5.1.2" - resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== - dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" - - strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - - strip-ansi@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== - dependencies: - ansi-regex "^6.0.1" - - supertap@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/supertap/-/supertap-3.0.1.tgz" - integrity sha512-u1ZpIBCawJnO+0QePsEiOknOfCRq0yERxiAchT0i4li0WHNUJbf0evXXSXOcCAR4M8iMDoajXYmstm/qO81Isw== - dependencies: - indent-string "^5.0.0" - js-yaml "^3.14.1" - serialize-error "^7.0.1" - strip-ansi "^7.0.1" - - supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - - supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - - tar@^6.1.0: - version "6.1.11" - resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== - dependencies: - chownr "^2.0.0" - fs-minipass "^2.0.0" - minipass "^3.0.0" - minizlib "^2.1.1" - mkdirp "^1.0.3" - yallist "^4.0.0" - - temp-dir@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz" - integrity sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg== - - text-encoding-utf-8@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz" - integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== - - time-zone@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz" - integrity sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA== - - to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== - - to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - - toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - - tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - - tweetnacl@^1.0.1: - version "1.0.3" - resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - - type-fest@^0.13.1: - version "0.13.1" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz" - integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== - - typescript@^4.7.4: - version "4.7.4" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== - - u3@^0.1.1: - version "0.1.1" - resolved "https://registry.npmjs.org/u3/-/u3-0.1.1.tgz" - integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== - - universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - - update-browserslist-db@^1.0.4: - version "1.0.5" - resolved "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38" - integrity sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q== - dependencies: - escalade "^3.1.1" - picocolors "^1.0.0" - - webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - - well-known-symbols@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz" - integrity sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q== - - whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - - wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - - wrappy@1: - version "1.0.2" - resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - - write-file-atomic@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.1.tgz" - integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ== - dependencies: - imurmurhash "^0.1.4" - signal-exit "^3.0.7" - - y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - - yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - - yargs-parser@^21.0.0: - version "21.0.1" - resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz" - integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== - - yargs@^17.5.1: - version "17.5.1" - resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz" - integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.0.0" - - yocto-queue@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz" - integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== diff --git a/packages/near-sdk-js/src/api.ts b/packages/near-sdk-js/src/api.ts index ee8e9a9db..8a2e9e0b7 100644 --- a/packages/near-sdk-js/src/api.ts +++ b/packages/near-sdk-js/src/api.ts @@ -135,6 +135,7 @@ interface Env { promise_result(promiseIndex: bigint, register: Register): PromiseResult; promise_return(promiseIndex: bigint): void; + // These are exported C functions that not part of NEAR VM Logic (host functions) uint8array_to_latin1_string(a: Uint8Array): string; uint8array_to_utf8_string(a: Uint8Array): string; latin1_string_to_uint8array(s: string): Uint8Array; diff --git a/tests/__tests__/test_highlevel_promise.ava.js b/tests/__tests__/test_highlevel_promise.ava.js index 6ec8c2718..f33abc988 100644 --- a/tests/__tests__/test_highlevel_promise.ava.js +++ b/tests/__tests__/test_highlevel_promise.ava.js @@ -168,9 +168,6 @@ test("cross contract call success then call a panic method", async (t) => { } ); // the last promise fail, cause the transaction fail - console.log( - r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError - ); t.assert( r.result.status.Failure.ActionError.kind.FunctionCallError.ExecutionError.includes( "Smart contract panicked: it just panic" diff --git a/tests/__tests__/test_promise_api.ava.js b/tests/__tests__/test_promise_api.ava.js index 80b7d5803..fe7492e44 100644 --- a/tests/__tests__/test_promise_api.ava.js +++ b/tests/__tests__/test_promise_api.ava.js @@ -234,7 +234,6 @@ test("promise batch deploy contract and call", async (t) => { "", { gas: "300 Tgas" } ); - console.log(JSON.stringify(r, null, 2)); let deployed = caller2Contract.getSubAccount("b"); t.deepEqual(JSON.parse(Buffer.from(r.result.status.SuccessValue, "base64")), { diff --git a/tests/yarn-error.log b/tests/yarn-error.log deleted file mode 100644 index c3ff9e9c5..000000000 --- a/tests/yarn-error.log +++ /dev/null @@ -1,2205 +0,0 @@ -Arguments: - /home/bo/.nvm/versions/node/v16.14.0/bin/node /home/bo/.nvm/versions/node/v16.14.0/bin/yarn add near-sdk-js - -PATH: - /home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/.pyenv/shims:/home/bo/.opam/4.07.1/bin:/home/bo/.nix-profile/bin:/home/bo/.local/bin:/home/bo/bin:/home/bo/Downloads/pkg/apache-maven-3.8.4/bin:/home/bo/.pyenv/shims:/home/bo/.pyenv/bin:/home/bo/.wasienv/bin:/home/bo/.wasmer/bin:/home/bo/.nvm/versions/node/v16.14.0/bin:/home/bo/.opam/4.07.1/bin:/home/bo/.cargo/bin:/home/bo/.nix-profile/bin:/home/bo/.local/bin:/home/bo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bo/.local/share/coursier/bin:/home/bo/Android/Sdk/tools/bin:/home/bo/Android/Sdk/platform-tools:/home/bo/Android/Sdk/emulator:/home/bo/Downloads/pkg/zig-linux-x86_64-0.8.1:/home/bo/Downloads/src/binaryen/bin:/home/bo/Downloads/src/wabt/bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin:/home/bo/.local/share/coursier/bin:/home/bo/Android/Sdk/tools/bin:/home/bo/Android/Sdk/platform-tools:/home/bo/Android/Sdk/emulator:/home/bo/Downloads/pkg/zig-linux-x86_64-0.8.1:/home/bo/Downloads/src/binaryen/bin:/home/bo/Downloads/src/wabt/bin:/usr/local/go/bin:/home/bo/go/bin:/home/bo/.wasmer/globals/wapm_packages/.bin - -Yarn version: - 1.22.17 - -Node version: - 16.14.0 - -Platform: - linux x64 - -Trace: - Error: getaddrinfo EAI_AGAIN registry.yarnpkg.com - at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) - -npm manifest: - { - "name": "tests", - "version": "1.0.0", - "description": "near-sdk-js tests", - "main": "index.js", - "type": "module", - "scripts": { - "postinstall": "cd .. && yarn link && cd tests && yarn link near-sdk-js", - "build": "run-s build:*", - "build:context-api": "near-sdk-js build src/context_api.js build/context_api.wasm", - "build:math-api": "near-sdk-js build src/math_api.js build/math_api.wasm", - "build:storage-api": "near-sdk-js build src/storage_api.js build/storage_api.wasm", - "build:log-panic-api": "near-sdk-js build src/log_panic_api.js build/log_panic_api.wasm", - "build:promise-api": "near-sdk-js build src/promise_api.js build/promise_api.wasm", - "build:promise-batch-api": "near-sdk-js build src/promise_batch_api.js build/promise_batch_api.wasm", - "build:highlevel-promise": "near-sdk-js build src/highlevel-promise.js build/highlevel-promise.wasm", - "build:function-params": "near-sdk-js build src/function-params.js build/function-params.wasm", - "build:lookup-map": "near-sdk-js build src/lookup-map.js build/lookup-map.wasm", - "build:lookup-set": "near-sdk-js build src/lookup-set.js build/lookup-set.wasm", - "build:unordered-map": "near-sdk-js build src/unordered-map.js build/unordered-map.wasm", - "build:unordered-set": "near-sdk-js build src/unordered-set.js build/unordered-set.wasm", - "build:vector": "near-sdk-js build src/vector.js build/vector.wasm", - "build:bytes": "near-sdk-js build src/bytes.js build/bytes.wasm", - "build:typescript": "near-sdk-js build src/typescript.ts build/typescript.wasm", - "build:public-key": "near-sdk-js build src/public-key.js build/public-key.wasm", - "build:near-bindgen": "near-sdk-js build src/decorators/require_init_true.ts build/require_init_true.wasm && near-sdk-js build src/decorators/require_init_false.ts build/require_init_false.wasm", - "build:payable": "near-sdk-js build src/decorators/payable.ts build/payable.wasm", - "build:private": "near-sdk-js build src/decorators/private.ts build/private.wasm", - "build:bigint-serialization": "near-sdk-js build src/bigint-serialization.ts build/bigint-serialization.wasm", - "build:date-serialization": "near-sdk-js build src/date-serialization.ts build/date-serialization.wasm", - "build:middlewares": "near-sdk-js build src/middlewares.ts build/middlewares.wasm", - "test": "ava", - "test:context-api": "ava __tests__/test_context_api.ava.js", - "test:math-api": "ava __tests__/test_math_api.ava.js", - "test:storage-api": "ava __tests__/test_storage_api.ava.js", - "test:log-panic-api": "ava __tests__/test_log_panic_api.ava.js", - "test:promise-api": "ava __tests__/test_promise_api.ava.js", - "test:highlevel-promise": "ava __tests__/test_highlevel_promise.ava.js", - "test:function-params": "ava __tests__/function-params.ava.js", - "test:lookup-map": "ava __tests__/lookup-map.ava.js", - "test:lookup-set": "ava __tests__/lookup-set.ava.js", - "test:unordered-set": "ava __tests__/unordered-set.ava.js", - "test:unordered-map": "ava __tests__/unordered-map.ava.js", - "test:vector": "ava __tests__/vector.ava.js", - "test:bytes": "ava __tests__/bytes.ava.js", - "test:typescript": "ava __tests__/typescript.ava.js", - "test:public-key": "ava __tests__/test-public-key.ava.js", - "test:near-bindgen": "ava __tests__/decorators/near_bindgen.ava.js", - "test:payable": "ava __tests__/decorators/payable.ava.js", - "test:private": "ava __tests__/decorators/private.ava.js", - "test:bigint-serialization": "ava __tests__/test-bigint-serialization.ava.js", - "test:date-serialization": "ava __tests__/test-date-serialization.ava.js", - "test:serialization": "ava __tests__/test-serialization.ava.js", - "test:constructor-validation": "ava __tests__/constructor_validation.ava.js", - "test:middlewares": "ava __tests__/test-middlewares.ava.js" - }, - "author": "Near Inc ", - "license": "Apache-2.0", - "devDependencies": { - "ava": "^4.2.0", - "near-workspaces": "3.2.1", - "npm-run-all": "^4.1.5", - "typescript": "^4.7.4" - } - } - -yarn manifest: - No manifest - -Lockfile: - # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. - # yarn lockfile v1 - - - "@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - - "@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - - "@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - - "@sindresorhus/is@^4.0.0": - version "4.6.0" - resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz" - integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== - - "@szmarczak/http-timer@^4.0.5": - version "4.0.6" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz" - integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== - dependencies: - defer-to-connect "^2.0.0" - - "@types/cacheable-request@^6.0.1": - version "6.0.2" - resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz" - integrity sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "*" - "@types/node" "*" - "@types/responselike" "*" - - "@types/http-cache-semantics@*": - version "4.0.1" - resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz" - integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== - - "@types/json-buffer@~3.0.0": - version "3.0.0" - resolved "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz" - integrity sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ== - - "@types/keyv@*": - version "3.1.4" - resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz" - integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== - dependencies: - "@types/node" "*" - - "@types/node@*": - version "18.0.0" - resolved "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz" - integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA== - - "@types/responselike@*", "@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - - acorn-walk@^8.2.0: - version "8.2.0" - resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - - acorn@^8.7.1: - version "8.7.1" - resolved "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - - aggregate-error@^3.0.0: - version "3.1.0" - resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz" - integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== - dependencies: - clean-stack "^2.0.0" - indent-string "^4.0.0" - - aggregate-error@^4.0.0: - version "4.0.1" - resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-4.0.1.tgz" - integrity sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w== - dependencies: - clean-stack "^4.0.0" - indent-string "^5.0.0" - - ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - - ansi-regex@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz" - integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== - - ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - - ansi-styles@^4.0.0: - version "4.3.0" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - - ansi-styles@^6.0.0, ansi-styles@^6.1.0: - version "6.1.0" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz" - integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== - - anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - - argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - - array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz" - integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== - - array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - - arrgv@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/arrgv/-/arrgv-1.0.2.tgz" - integrity sha512-a4eg4yhp7mmruZDQFqVMlxNRFGi/i1r87pt8SDHy0/I8PqSXoUTlWZRdAZo0VXgvEARcujbtTk8kiZRi1uDGRw== - - arrify@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/arrify/-/arrify-3.0.0.tgz" - integrity sha512-tLkvA81vQG/XqE2mjDkGQHoOINtMHtysSnemrmoGe6PydDPMRbVugqyk4A6V/WDWEfm3l+0d8anA9r8cv/5Jaw== - - ava@^4.2.0: - version "4.3.0" - resolved "https://registry.npmjs.org/ava/-/ava-4.3.0.tgz" - integrity sha512-Ap0u8rp8wOBN6CxshgxrPSe191e8g52RWGoXeDB57ubo4fyZyStfI6OxQi/bl0yxIDEOYHhCiGwihbzlMNJw3Q== - dependencies: - acorn "^8.7.1" - acorn-walk "^8.2.0" - ansi-styles "^6.1.0" - arrgv "^1.0.2" - arrify "^3.0.0" - callsites "^4.0.0" - cbor "^8.1.0" - chalk "^5.0.1" - chokidar "^3.5.3" - chunkd "^2.0.1" - ci-info "^3.3.1" - ci-parallel-vars "^1.0.1" - clean-yaml-object "^0.1.0" - cli-truncate "^3.1.0" - code-excerpt "^4.0.0" - common-path-prefix "^3.0.0" - concordance "^5.0.4" - currently-unhandled "^0.4.1" - debug "^4.3.4" - del "^6.1.1" - emittery "^0.11.0" - figures "^4.0.1" - globby "^13.1.1" - ignore-by-default "^2.1.0" - indent-string "^5.0.0" - is-error "^2.2.2" - is-plain-object "^5.0.0" - is-promise "^4.0.0" - matcher "^5.0.0" - mem "^9.0.2" - ms "^2.1.3" - p-event "^5.0.1" - p-map "^5.4.0" - picomatch "^2.3.1" - pkg-conf "^4.0.0" - plur "^5.1.0" - pretty-ms "^7.0.1" - resolve-cwd "^3.0.0" - slash "^3.0.0" - stack-utils "^2.0.5" - strip-ansi "^7.0.1" - supertap "^3.0.1" - temp-dir "^2.0.0" - write-file-atomic "^4.0.1" - yargs "^17.5.1" - - balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - - base-x@^3.0.2: - version "3.0.9" - resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - - base64url@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz" - integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== - - binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - - blueimp-md5@^2.10.0: - version "2.19.0" - resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz" - integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w== - - bn.js@5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - - bn.js@^5.2.0: - version "5.2.1" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== - - borsh@^0.5.0: - version "0.5.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.5.0.tgz" - integrity sha512-p9w/qGBeeFdUf2GPBPHdX5JQyez8K5VtoFN7PqSfmR+cVUMSmcwAKhP9n2aXoDSKbtS7xZlZt3MVnrJL7GdYhg== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - - borsh@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/borsh/-/borsh-0.6.0.tgz" - integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - - brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - - braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - - bs58@^4.0.0, bs58@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz" - integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== - dependencies: - base-x "^3.0.2" - - cacheable-lookup@^5.0.3: - version "5.0.4" - resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz" - integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== - - cacheable-request@^7.0.2: - version "7.0.2" - resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz" - integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^6.0.1" - responselike "^2.0.0" - - call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - - callsites@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/callsites/-/callsites-4.0.0.tgz" - integrity sha512-y3jRROutgpKdz5vzEhWM34TidDU8vkJppF8dszITeb1PQmSqV3DTxyV8G/lyO/DNvtE1YTedehmw9MPZsCBHxQ== - - capability@^0.2.5: - version "0.2.5" - resolved "https://registry.npmjs.org/capability/-/capability-0.2.5.tgz" - integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== - - cbor@^8.1.0: - version "8.1.0" - resolved "https://registry.npmjs.org/cbor/-/cbor-8.1.0.tgz" - integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== - dependencies: - nofilter "^3.1.0" - - chalk@^2.4.1: - version "2.4.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - - chalk@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz" - integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== - - chokidar@^3.5.3: - version "3.5.3" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - - chownr@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" - integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== - - chunkd@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/chunkd/-/chunkd-2.0.1.tgz" - integrity sha512-7d58XsFmOq0j6el67Ug9mHf9ELUXsQXYJBkyxhH/k+6Ke0qXRnv0kbemx+Twc6fRJ07C49lcbdgm9FL1Ei/6SQ== - - ci-info@^3.3.1: - version "3.3.2" - resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz" - integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg== - - ci-parallel-vars@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/ci-parallel-vars/-/ci-parallel-vars-1.0.1.tgz" - integrity sha512-uvzpYrpmidaoxvIQHM+rKSrigjOe9feHYbw4uOI2gdfe1C3xIlxO+kVXq83WQWNniTf8bAxVpy+cQeFQsMERKg== - - clean-stack@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz" - integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== - - clean-stack@^4.0.0: - version "4.2.0" - resolved "https://registry.npmjs.org/clean-stack/-/clean-stack-4.2.0.tgz" - integrity sha512-LYv6XPxoyODi36Dp976riBtSY27VmFo+MKqEU9QCCWyTrdEPDog+RWA7xQWHi6Vbp61j5c4cdzzX1NidnwtUWg== - dependencies: - escape-string-regexp "5.0.0" - - clean-yaml-object@^0.1.0: - version "0.1.0" - resolved "https://registry.npmjs.org/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz" - integrity sha512-3yONmlN9CSAkzNwnRCiJQ7Q2xK5mWuEfL3PuTZcAUzhObbXsfsnMptJzXwz93nc5zn9V9TwCVMmV7w4xsm43dw== - - cli-truncate@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz" - integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== - dependencies: - slice-ansi "^5.0.0" - string-width "^5.0.0" - - cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - - clone-response@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz" - integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== - dependencies: - mimic-response "^1.0.0" - - code-excerpt@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz" - integrity sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA== - dependencies: - convert-to-spaces "^2.0.1" - - color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - - color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - - color-name@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" - integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== - - color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - - common-path-prefix@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz" - integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w== - - compress-brotli@^1.3.8: - version "1.3.8" - resolved "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz" - integrity sha512-lVcQsjhxhIXsuupfy9fmZUFtAIdBmXA7EGY6GBdgZ++qkM9zG4YFT8iU7FoBxzryNDMOpD1HIFHUSX4D87oqhQ== - dependencies: - "@types/json-buffer" "~3.0.0" - json-buffer "~3.0.1" - - concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - - concordance@^5.0.4: - version "5.0.4" - resolved "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz" - integrity sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw== - dependencies: - date-time "^3.1.0" - esutils "^2.0.3" - fast-diff "^1.2.0" - js-string-escape "^1.0.1" - lodash "^4.17.15" - md5-hex "^3.0.1" - semver "^7.3.2" - well-known-symbols "^2.0.0" - - convert-to-spaces@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz" - integrity sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ== - - cross-spawn@^6.0.5: - version "6.0.5" - resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - - currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz" - integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== - dependencies: - array-find-index "^1.0.1" - - date-time@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz" - integrity sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg== - dependencies: - time-zone "^1.0.0" - - debug@^4.3.4: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - - decompress-response@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz" - integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== - dependencies: - mimic-response "^3.1.0" - - defer-to-connect@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz" - integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== - - define-properties@^1.1.3, define-properties@^1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz" - integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== - dependencies: - has-property-descriptors "^1.0.0" - object-keys "^1.1.1" - - del@^6.1.1: - version "6.1.1" - resolved "https://registry.npmjs.org/del/-/del-6.1.1.tgz" - integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg== - dependencies: - globby "^11.0.1" - graceful-fs "^4.2.4" - is-glob "^4.0.1" - is-path-cwd "^2.2.0" - is-path-inside "^3.0.2" - p-map "^4.0.0" - rimraf "^3.0.2" - slash "^3.0.0" - - depd@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - - depd@~1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - - dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - - eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - - emittery@^0.11.0: - version "0.11.0" - resolved "https://registry.npmjs.org/emittery/-/emittery-0.11.0.tgz" - integrity sha512-S/7tzL6v5i+4iJd627Nhv9cLFIo5weAIlGccqJFpnBoDB8U1TF2k5tez4J/QNuxyyhWuFqHg1L84Kd3m7iXg6g== - - emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - - emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - - end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - - error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - - error-polyfill@^0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/error-polyfill/-/error-polyfill-0.1.3.tgz" - integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== - dependencies: - capability "^0.2.5" - o3 "^1.0.3" - u3 "^0.1.1" - - es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.5: - version "1.20.4" - resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz" - integrity sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - function.prototype.name "^1.1.5" - get-intrinsic "^1.1.3" - get-symbol-description "^1.0.0" - has "^1.0.3" - has-property-descriptors "^1.0.0" - has-symbols "^1.0.3" - internal-slot "^1.0.3" - is-callable "^1.2.7" - is-negative-zero "^2.0.2" - is-regex "^1.1.4" - is-shared-array-buffer "^1.0.2" - is-string "^1.0.7" - is-weakref "^1.0.2" - object-inspect "^1.12.2" - object-keys "^1.1.1" - object.assign "^4.1.4" - regexp.prototype.flags "^1.4.3" - safe-regex-test "^1.0.0" - string.prototype.trimend "^1.0.5" - string.prototype.trimstart "^1.0.5" - unbox-primitive "^1.0.2" - - es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - - escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - - escape-string-regexp@5.0.0, escape-string-regexp@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz" - integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== - - escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - - escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - - esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - - esutils@^2.0.3: - version "2.0.3" - resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - - fast-diff@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz" - integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== - - fast-glob@^3.2.11, fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - - fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" - - figures@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/figures/-/figures-4.0.1.tgz" - integrity sha512-rElJwkA/xS04Vfg+CaZodpso7VqBknOYbzi6I76hI4X80RUjkSxO2oAyPmGbuXUppywjqndOrQDl817hDnI++w== - dependencies: - escape-string-regexp "^5.0.0" - is-unicode-supported "^1.2.0" - - fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - - find-up@^6.0.0: - version "6.3.0" - resolved "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz" - integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw== - dependencies: - locate-path "^7.1.0" - path-exists "^5.0.0" - - fs-extra@^10.0.0: - version "10.1.0" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz" - integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - - fs-minipass@^2.0.0: - version "2.1.0" - resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz" - integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== - dependencies: - minipass "^3.0.0" - - fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - - fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - - function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - - function.prototype.name@^1.1.5: - version "1.1.5" - resolved "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz" - integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.0" - functions-have-names "^1.2.2" - - functions-have-names@^1.2.2: - version "1.2.3" - resolved "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz" - integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== - - get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - - get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz" - integrity sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.3" - - get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - - get-symbol-description@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz" - integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== - dependencies: - call-bind "^1.0.2" - get-intrinsic "^1.1.1" - - glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - - glob@^7.1.3: - version "7.2.3" - resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - - globby@^11.0.1: - version "11.1.0" - resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - - globby@^13.1.1: - version "13.1.2" - resolved "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz" - integrity sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ== - dependencies: - dir-glob "^3.0.1" - fast-glob "^3.2.11" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^4.0.0" - - got@^11.8.2: - version "11.8.5" - resolved "https://registry.npmjs.org/got/-/got-11.8.5.tgz" - integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ== - dependencies: - "@sindresorhus/is" "^4.0.0" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.2" - decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" - - graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: - version "4.2.10" - resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - - has-bigints@^1.0.1, has-bigints@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz" - integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== - - has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" - integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== - - has-property-descriptors@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz" - integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== - dependencies: - get-intrinsic "^1.1.1" - - has-symbols@^1.0.2, has-symbols@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" - integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== - - has-tostringtag@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz" - integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== - dependencies: - has-symbols "^1.0.2" - - has@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - - hosted-git-info@^2.1.4: - version "2.8.9" - resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz" - integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== - - http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== - - http-errors@^1.7.2: - version "1.8.1" - resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - - http2-wrapper@^1.0.0-beta.5.2: - version "1.0.3" - resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz" - integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.0.0" - - ignore-by-default@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-2.1.0.tgz" - integrity sha512-yiWd4GVmJp0Q6ghmM2B/V3oZGRmjrKLXvHR3TE1nfoXsmoggllfZUQe74EN0fJdPFZu2NIvNdrMMLm3OsV7Ohw== - - ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - - imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" - integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== - - indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - - indent-string@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz" - integrity sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg== - - inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - - inherits@2, inherits@2.0.4: - version "2.0.4" - resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - - internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== - dependencies: - get-intrinsic "^1.1.0" - has "^1.0.3" - side-channel "^1.0.4" - - irregular-plurals@^3.3.0: - version "3.3.0" - resolved "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.3.0.tgz" - integrity sha512-MVBLKUTangM3EfRPFROhmWQQKRDsrgI83J8GS3jXy+OwYqiR2/aoWndYQ5416jLE3uaGgLH7ncme3X9y09gZ3g== - - is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" - integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== - - is-bigint@^1.0.1: - version "1.0.4" - resolved "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz" - integrity sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg== - dependencies: - has-bigints "^1.0.1" - - is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - - is-boolean-object@^1.1.0: - version "1.1.2" - resolved "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz" - integrity sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - - is-callable@^1.1.4, is-callable@^1.2.7: - version "1.2.7" - resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz" - integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== - - is-core-module@^2.9.0: - version "2.11.0" - resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz" - integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== - dependencies: - has "^1.0.3" - - is-date-object@^1.0.1: - version "1.0.5" - resolved "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz" - integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== - dependencies: - has-tostringtag "^1.0.0" - - is-error@^2.2.2: - version "2.2.2" - resolved "https://registry.npmjs.org/is-error/-/is-error-2.2.2.tgz" - integrity sha512-IOQqts/aHWbiisY5DuPJQ0gcbvaLFCa7fBa9xoLfxBZvQ+ZI/Zh9xoI7Gk+G64N0FdK4AbibytHht2tWgpJWLg== - - is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - - is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - - is-fullwidth-code-point@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz" - integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== - - is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - - is-negative-zero@^2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz" - integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== - - is-number-object@^1.0.4: - version "1.0.7" - resolved "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz" - integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== - dependencies: - has-tostringtag "^1.0.0" - - is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - - is-path-cwd@^2.2.0: - version "2.2.0" - resolved "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz" - integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== - - is-path-inside@^3.0.2: - version "3.0.3" - resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz" - integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== - - is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - - is-promise@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz" - integrity sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ== - - is-regex@^1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz" - integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - - is-shared-array-buffer@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz" - integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== - dependencies: - call-bind "^1.0.2" - - is-string@^1.0.5, is-string@^1.0.7: - version "1.0.7" - resolved "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz" - integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== - dependencies: - has-tostringtag "^1.0.0" - - is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.4" - resolved "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz" - integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== - dependencies: - has-symbols "^1.0.2" - - is-unicode-supported@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz" - integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ== - - is-weakref@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz" - integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== - dependencies: - call-bind "^1.0.2" - - isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" - integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== - - js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - - js-string-escape@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz" - integrity sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg== - - js-yaml@^3.14.1: - version "3.14.1" - resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - - json-buffer@3.0.1, json-buffer@~3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" - integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== - - json-parse-better-errors@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== - - jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - - keyv@^4.0.0: - version "4.3.3" - resolved "https://registry.npmjs.org/keyv/-/keyv-4.3.3.tgz" - integrity sha512-AcysI17RvakTh8ir03+a3zJr5r0ovnAH/XTXei/4HIv3bL2K/jzvgivLK9UuI/JbU1aJjM3NSAnVvVVd3n+4DQ== - dependencies: - compress-brotli "^1.3.8" - json-buffer "3.0.1" - - load-json-file@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz" - integrity sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw== - dependencies: - graceful-fs "^4.1.2" - parse-json "^4.0.0" - pify "^3.0.0" - strip-bom "^3.0.0" - - load-json-file@^7.0.0: - version "7.0.1" - resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-7.0.1.tgz" - integrity sha512-Gnxj3ev3mB5TkVBGad0JM6dmLiQL+o0t23JPBZ9sd+yvSLk05mFoqKBw5N8gbbkU4TNXyqCgIrl/VM17OgUIgQ== - - locate-path@^7.1.0: - version "7.1.1" - resolved "https://registry.npmjs.org/locate-path/-/locate-path-7.1.1.tgz" - integrity sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg== - dependencies: - p-locate "^6.0.0" - - lodash@^4.17.15: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - - lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - - lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - - map-age-cleaner@^0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - - matcher@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/matcher/-/matcher-5.0.0.tgz" - integrity sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw== - dependencies: - escape-string-regexp "^5.0.0" - - md5-hex@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz" - integrity sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw== - dependencies: - blueimp-md5 "^2.10.0" - - mem@^9.0.2: - version "9.0.2" - resolved "https://registry.npmjs.org/mem/-/mem-9.0.2.tgz" - integrity sha512-F2t4YIv9XQUBHt6AOJ0y7lSmP1+cY7Fm1DRh9GClTGzKST7UWLMx6ly9WZdLH/G/ppM5RL4MlQfRT71ri9t19A== - dependencies: - map-age-cleaner "^0.1.3" - mimic-fn "^4.0.0" - - memorystream@^0.3.1: - version "0.3.1" - resolved "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz" - integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== - - merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - - micromatch@^4.0.4: - version "4.0.5" - resolved "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - - mimic-fn@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz" - integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== - - mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - - mimic-response@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz" - integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== - - minimatch@^3.0.4, minimatch@^3.1.1: - version "3.1.2" - resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - - minipass@^3.0.0: - version "3.3.4" - resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz" - integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw== - dependencies: - yallist "^4.0.0" - - minizlib@^2.1.1: - version "2.1.2" - resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" - integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== - dependencies: - minipass "^3.0.0" - yallist "^4.0.0" - - mkdirp@^1.0.3: - version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - - ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - - ms@^2.1.3: - version "2.1.3" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - - mustache@^4.0.0: - version "4.2.0" - resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" - integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== - - near-api-js@^0.44.1: - version "0.44.2" - resolved "https://registry.npmjs.org/near-api-js/-/near-api-js-0.44.2.tgz" - integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== - dependencies: - bn.js "5.2.0" - borsh "^0.6.0" - bs58 "^4.0.0" - depd "^2.0.0" - error-polyfill "^0.1.3" - http-errors "^1.7.2" - js-sha256 "^0.9.0" - mustache "^4.0.0" - node-fetch "^2.6.1" - text-encoding-utf-8 "^1.0.2" - tweetnacl "^1.0.1" - - near-sandbox@^0.0.13: - version "0.0.13" - resolved "https://registry.npmjs.org/near-sandbox/-/near-sandbox-0.0.13.tgz" - integrity sha512-rtRn51BBD1oT9SeGAIInKVedfaS/i4VqKqznZIvFddWo0jcI4lMoK1yHuTVuEE7YfEE12NsspFG1GxN1SlPV2g== - dependencies: - got "^11.8.2" - tar "^6.1.0" - - near-units@^0.1.9: - version "0.1.9" - resolved "https://registry.npmjs.org/near-units/-/near-units-0.1.9.tgz" - integrity sha512-xiuBjpNsi+ywiu7P6iWRZdgFm7iCr/cfWlVO6+e5uaAqH4mE1rrurElyrL91llNDSnMwogd9XmlZOw5KbbHNsA== - dependencies: - bn.js "^5.2.0" - - near-workspaces@3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/near-workspaces/-/near-workspaces-3.2.1.tgz" - integrity sha512-761D8lsbSetS+Nu9C4IWdONn0gBSVpfjY8V09AOQt1Zb5XjtURFWpFTZun6vQJhvWv5+RsSNTF6uYsLyTLJBAA== - dependencies: - base64url "^3.0.1" - bn.js "^5.2.0" - borsh "^0.5.0" - bs58 "^4.0.1" - callsites "^4.0.0" - fs-extra "^10.0.0" - js-sha256 "^0.9.0" - near-api-js "^0.44.1" - near-sandbox "^0.0.13" - near-units "^0.1.9" - node-port-check "^2.0.1" - promisify-child-process "^4.1.1" - pure-uuid "^1.6.2" - rimraf "^3.0.2" - temp-dir "^2.0.0" - - nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== - - node-fetch@^2.6.1: - version "2.6.7" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - - node-port-check@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/node-port-check/-/node-port-check-2.0.1.tgz" - integrity sha512-PV1tj5OPbWwxvhPcChXxwCIKl/IfVEdPP4u/gQz2lao/VGoeIUXb/4U72KSHLZpTVBmgTnMm0me7yR0wUsIuPg== - - nofilter@^3.1.0: - version "3.1.0" - resolved "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz" - integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== - - normalize-package-data@^2.3.2: - version "2.5.0" - resolved "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - - normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - - normalize-url@^6.0.1: - version "6.1.0" - resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz" - integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== - - npm-run-all@^4.1.5: - version "4.1.5" - resolved "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz" - integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ== - dependencies: - ansi-styles "^3.2.1" - chalk "^2.4.1" - cross-spawn "^6.0.5" - memorystream "^0.3.1" - minimatch "^3.0.4" - pidtree "^0.3.0" - read-pkg "^3.0.0" - shell-quote "^1.6.1" - string.prototype.padend "^3.0.0" - - o3@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/o3/-/o3-1.0.3.tgz" - integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== - dependencies: - capability "^0.2.5" - - object-inspect@^1.12.2, object-inspect@^1.9.0: - version "1.12.2" - resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz" - integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== - - object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - - object.assign@^4.1.4: - version "4.1.4" - resolved "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz" - integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - has-symbols "^1.0.3" - object-keys "^1.1.1" - - once@^1.3.0, once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - - p-cancelable@^2.0.0: - version "2.1.1" - resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz" - integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== - - p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz" - integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw== - - p-event@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/p-event/-/p-event-5.0.1.tgz" - integrity sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ== - dependencies: - p-timeout "^5.0.2" - - p-limit@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz" - integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ== - dependencies: - yocto-queue "^1.0.0" - - p-locate@^6.0.0: - version "6.0.0" - resolved "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz" - integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw== - dependencies: - p-limit "^4.0.0" - - p-map@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz" - integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== - dependencies: - aggregate-error "^3.0.0" - - p-map@^5.4.0: - version "5.5.0" - resolved "https://registry.npmjs.org/p-map/-/p-map-5.5.0.tgz" - integrity sha512-VFqfGDHlx87K66yZrNdI4YGtD70IRyd+zSvgks6mzHPRNkoKy+9EKP4SFC77/vTTQYmRmti7dvqC+m5jBrBAcg== - dependencies: - aggregate-error "^4.0.0" - - p-timeout@^5.0.2: - version "5.1.0" - resolved "https://registry.npmjs.org/p-timeout/-/p-timeout-5.1.0.tgz" - integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew== - - parse-json@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz" - integrity sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw== - dependencies: - error-ex "^1.3.1" - json-parse-better-errors "^1.0.1" - - parse-ms@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz" - integrity sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA== - - path-exists@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz" - integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ== - - path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - - path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz" - integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== - - path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - - path-type@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz" - integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== - dependencies: - pify "^3.0.0" - - path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - - picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - - pidtree@^0.3.0: - version "0.3.1" - resolved "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz" - integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA== - - pify@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz" - integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== - - pkg-conf@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/pkg-conf/-/pkg-conf-4.0.0.tgz" - integrity sha512-7dmgi4UY4qk+4mj5Cd8v/GExPo0K+SlY+hulOSdfZ/T6jVH6//y7NtzZo5WrfhDBxuQ0jCa7fLZmNaNh7EWL/w== - dependencies: - find-up "^6.0.0" - load-json-file "^7.0.0" - - plur@^5.1.0: - version "5.1.0" - resolved "https://registry.npmjs.org/plur/-/plur-5.1.0.tgz" - integrity sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg== - dependencies: - irregular-plurals "^3.3.0" - - pretty-ms@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz" - integrity sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q== - dependencies: - parse-ms "^2.1.0" - - promisify-child-process@^4.1.1: - version "4.1.1" - resolved "https://registry.npmjs.org/promisify-child-process/-/promisify-child-process-4.1.1.tgz" - integrity sha512-/sRjHZwoXf1rJ+8s4oWjYjGRVKNK1DUnqfRC1Zek18pl0cN6k3yJ1cCbqd0tWNe4h0Gr+SY4vR42N33+T82WkA== - - pump@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - - pure-uuid@^1.6.2: - version "1.6.2" - resolved "https://registry.npmjs.org/pure-uuid/-/pure-uuid-1.6.2.tgz" - integrity sha512-WQ4xz74ApW6s0BToRuuyuMo9g0VHx1HljY0H2gPng+mqqz/K1yLj7sHZonZZQ2++WfHl/ZzruilWvuz+WtmxjQ== - - queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - - quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - - read-pkg@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz" - integrity sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA== - dependencies: - load-json-file "^4.0.0" - normalize-package-data "^2.3.2" - path-type "^3.0.0" - - readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - - regexp.prototype.flags@^1.4.3: - version "1.4.3" - resolved "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz" - integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - functions-have-names "^1.2.2" - - require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - - resolve-alpn@^1.0.0: - version "1.2.1" - resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" - integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== - - resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - - resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - - resolve@^1.10.0: - version "1.22.1" - resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz" - integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== - dependencies: - is-core-module "^2.9.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - - responselike@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz" - integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== - dependencies: - lowercase-keys "^2.0.0" - - reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - - rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - - run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - - safe-buffer@^5.0.1: - version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - - safe-regex-test@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz" - integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== - dependencies: - call-bind "^1.0.2" - get-intrinsic "^1.1.3" - is-regex "^1.1.4" - - "semver@2 || 3 || 4 || 5", semver@^5.5.0: - version "5.7.1" - resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - - semver@^7.3.2: - version "7.3.7" - resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - - serialize-error@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz" - integrity sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw== - dependencies: - type-fest "^0.13.1" - - setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - - shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz" - integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== - dependencies: - shebang-regex "^1.0.0" - - shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz" - integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== - - shell-quote@^1.6.1: - version "1.7.4" - resolved "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.4.tgz" - integrity sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw== - - side-channel@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz" - integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== - dependencies: - call-bind "^1.0.0" - get-intrinsic "^1.0.2" - object-inspect "^1.9.0" - - signal-exit@^3.0.7: - version "3.0.7" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - - slash@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - - slash@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz" - integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== - - slice-ansi@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz" - integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== - dependencies: - ansi-styles "^6.0.0" - is-fullwidth-code-point "^4.0.0" - - spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - - spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - - spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - - spdx-license-ids@^3.0.0: - version "3.0.12" - resolved "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz" - integrity sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA== - - sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" - integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== - - stack-utils@^2.0.5: - version "2.0.5" - resolved "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== - dependencies: - escape-string-regexp "^2.0.0" - - "statuses@>= 1.5.0 < 2": - version "1.5.0" - resolved "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - - string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - - string-width@^5.0.0: - version "5.1.2" - resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== - dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" - - string.prototype.padend@^3.0.0: - version "3.1.3" - resolved "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.3.tgz" - integrity sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" - - string.prototype.trimend@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz" - integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.19.5" - - string.prototype.trimstart@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz" - integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.19.5" - - strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - - strip-ansi@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== - dependencies: - ansi-regex "^6.0.1" - - strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz" - integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== - - supertap@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/supertap/-/supertap-3.0.1.tgz" - integrity sha512-u1ZpIBCawJnO+0QePsEiOknOfCRq0yERxiAchT0i4li0WHNUJbf0evXXSXOcCAR4M8iMDoajXYmstm/qO81Isw== - dependencies: - indent-string "^5.0.0" - js-yaml "^3.14.1" - serialize-error "^7.0.1" - strip-ansi "^7.0.1" - - supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - - supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - - tar@^6.1.0: - version "6.1.11" - resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== - dependencies: - chownr "^2.0.0" - fs-minipass "^2.0.0" - minipass "^3.0.0" - minizlib "^2.1.1" - mkdirp "^1.0.3" - yallist "^4.0.0" - - temp-dir@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz" - integrity sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg== - - text-encoding-utf-8@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz" - integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== - - time-zone@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz" - integrity sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA== - - to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - - toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - - tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - - tweetnacl@^1.0.1: - version "1.0.3" - resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - - type-fest@^0.13.1: - version "0.13.1" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz" - integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== - - typescript@^4.7.4: - version "4.7.4" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== - - u3@^0.1.1: - version "0.1.1" - resolved "https://registry.npmjs.org/u3/-/u3-0.1.1.tgz" - integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== - - unbox-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz" - integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== - dependencies: - call-bind "^1.0.2" - has-bigints "^1.0.2" - has-symbols "^1.0.3" - which-boxed-primitive "^1.0.2" - - universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== - - validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - - webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - - well-known-symbols@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz" - integrity sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q== - - whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - - which-boxed-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - - which@^1.2.9: - version "1.3.1" - resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - - wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - - wrappy@1: - version "1.0.2" - resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - - write-file-atomic@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.1.tgz" - integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ== - dependencies: - imurmurhash "^0.1.4" - signal-exit "^3.0.7" - - y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - - yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - - yargs-parser@^21.0.0: - version "21.0.1" - resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz" - integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== - - yargs@^17.5.1: - version "17.5.1" - resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz" - integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.0.0" - - yocto-queue@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz" - integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== From e8f9c08cf5e30d17323a2136ac1c94548eb842db Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 13 Dec 2022 16:29:07 +0800 Subject: [PATCH 23/24] keep string APIs mostly backward compatible, make raw apis, fix tests --- examples/src/clean-state.js | 12 +- examples/src/counter-lowlevel.js | 20 +- examples/src/cross-contract-call-loop.js | 13 +- examples/src/cross-contract-call.js | 12 +- examples/src/fungible-token.ts | 3 +- examples/src/non-fungible-token.js | 9 +- examples/src/programmatic-update-after.ts | 16 +- examples/src/programmatic-update-before.ts | 16 +- examples/src/standard-nft/my-nft.ts | 16 +- .../standard-nft/test-approval-receiver.ts | 2 +- .../src/standard-nft/test-token-receiver.ts | 4 +- .../lib/non_fungible_token/impl.d.ts | 4 +- .../lib/non_fungible_token/impl.js | 32 +-- .../lib/non_fungible_token/utils.d.ts | 2 +- .../src/non_fungible_token/impl.ts | 35 ++- .../src/non_fungible_token/utils.ts | 2 +- packages/near-sdk-js/lib/api.d.ts | 111 +++++++++- packages/near-sdk-js/lib/api.js | 141 ++++++++++-- .../near-sdk-js/lib/collections/lookup-map.js | 12 +- .../near-sdk-js/lib/collections/lookup-set.js | 8 +- .../lib/collections/unordered-set.js | 16 +- .../near-sdk-js/lib/collections/vector.js | 18 +- packages/near-sdk-js/lib/near-bindgen.js | 8 +- packages/near-sdk-js/lib/promise.d.ts | 63 +++++- packages/near-sdk-js/lib/promise.js | 79 ++++++- packages/near-sdk-js/src/api.ts | 207 ++++++++++++++++-- .../near-sdk-js/src/collections/lookup-map.ts | 12 +- .../near-sdk-js/src/collections/lookup-set.ts | 8 +- .../src/collections/unordered-set.ts | 16 +- .../near-sdk-js/src/collections/vector.ts | 24 +- packages/near-sdk-js/src/near-bindgen.ts | 8 +- packages/near-sdk-js/src/promise.ts | 117 +++++++++- tests/src/bytes.js | 16 +- tests/src/context_api.js | 30 +-- tests/src/highlevel-promise.js | 14 +- tests/src/promise_api.js | 12 +- tests/src/storage_api.js | 20 +- 37 files changed, 858 insertions(+), 280 deletions(-) diff --git a/examples/src/clean-state.js b/examples/src/clean-state.js index 827328dbd..7021a6097 100644 --- a/examples/src/clean-state.js +++ b/examples/src/clean-state.js @@ -1,23 +1,19 @@ -import { NearBindgen, call, view, near, encode, decode } from "near-sdk-js"; +import { NearBindgen, call, view, near } from "near-sdk-js"; @NearBindgen({}) export class CleanState { @call({}) clean({ keys }) { - keys.forEach((key) => near.storageRemove(encode(key))); + keys.forEach((key) => near.storageRemove(key)); } @call({}) put({ key, value }) { - near.storageWrite(encode(key), encode(value)); + near.storageWrite(key, value); } @view({}) get({ key }) { - let raw = near.storageRead(encode(key)); - if (raw !== null) { - return decode(raw); - } - return null; + return near.storageRead(key); } } diff --git a/examples/src/counter-lowlevel.js b/examples/src/counter-lowlevel.js index 84414839b..f01249ad2 100644 --- a/examples/src/counter-lowlevel.js +++ b/examples/src/counter-lowlevel.js @@ -1,19 +1,19 @@ // This contract implements exact same functionality as counter.js, but only use low level APIs -import { near, bytes, str } from "near-sdk-js"; +import { near } from "near-sdk-js"; export function init() { let argsRaw = near.input(); - let args = JSON.parse(str(argsRaw) || "{}"); + let args = JSON.parse(argsRaw || "{}"); let initial = args.initial || 0; let count = initial; let state = JSON.stringify({ count }); - near.storageWrite(bytes("STATE"), bytes(state)); + near.storageWrite("STATE", state); } function deserialize() { - let state = near.storageRead(bytes("STATE")); + let state = near.storageRead("STATE"); if (state) { - return JSON.parse(str(state)); + return JSON.parse(state); } else { return { count: 0 }; } @@ -22,25 +22,25 @@ function deserialize() { export function getCount() { let state = deserialize(); let count = state.count; - near.valueReturn(bytes(JSON.stringify(count))); + near.valueReturn(JSON.stringify(count)); } export function increase() { let argsRaw = near.input(); - let args = JSON.parse(str(argsRaw) || "{}"); + let args = JSON.parse(argsRaw || "{}"); let n = args.n || 1; let state = deserialize(); state.count += n; near.log(`Counter increased to ${state.count}`); - near.storageWrite(bytes("STATE"), bytes(JSON.stringify(state))); + near.storageWrite("STATE", JSON.stringify(state)); } export function decrease() { let argsRaw = near.input(); - let args = JSON.parse(str(argsRaw) || "{}"); + let args = JSON.parse(argsRaw || "{}"); let n = args.n || 1; let state = deserialize(); state.count -= n; near.log(`Counter decreased to ${state.count}`); - near.storageWrite(bytes("STATE"), bytes(JSON.stringify(state))); + near.storageWrite("STATE", JSON.stringify(state)); } diff --git a/examples/src/cross-contract-call-loop.js b/examples/src/cross-contract-call-loop.js index f67c78332..bd46e6d71 100644 --- a/examples/src/cross-contract-call-loop.js +++ b/examples/src/cross-contract-call-loop.js @@ -1,18 +1,11 @@ -import { - call, - near, - NearBindgen, - NearPromise, - view, - decode, -} from "near-sdk-js"; +import { call, near, NearBindgen, NearPromise, view } from "near-sdk-js"; const CONTRACTS = [ "first-contract.test.near", "second-contract.test.near", "third-contract.test.near", ]; -const NO_ARGS = new Uint8Array(); +const NO_ARGS = ""; const THIRTY_TGAS = BigInt("30" + "0".repeat(12)); @NearBindgen({}) @@ -55,7 +48,7 @@ export class LoopXCC { const callCount = near.promiseResultsCount(); for (let i = 0; i < callCount; i++) { const promiseResult = near.promiseResult(i); - const result = JSON.parse(decode(promiseResult)); + const result = JSON.parse(promiseResult); this.count += result; } return this.count; diff --git a/examples/src/cross-contract-call.js b/examples/src/cross-contract-call.js index 0d12fa856..2272e81fd 100644 --- a/examples/src/cross-contract-call.js +++ b/examples/src/cross-contract-call.js @@ -1,12 +1,4 @@ -import { - NearBindgen, - call, - view, - initialize, - near, - bytes, - str, -} from "near-sdk-js"; +import { NearBindgen, call, view, initialize, near, bytes } from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class OnCall { @@ -45,7 +37,7 @@ export class OnCall { @call({ privateFunction: true }) _set_person_on_call_private({ accountId }) { near.log(`_set_person_on_call_private called, accountId ${accountId}`); - const status = JSON.parse(str(near.promiseResult(0))); + const status = JSON.parse(near.promiseResult(0)); near.log(`${accountId} status is ${status}`); if (status === "AVAILABLE") { this.personOnCall = accountId; diff --git a/examples/src/fungible-token.ts b/examples/src/fungible-token.ts index 37b4f36a7..8a4aa7ee6 100644 --- a/examples/src/fungible-token.ts +++ b/examples/src/fungible-token.ts @@ -7,7 +7,6 @@ import { LookupMap, assert, validateAccountId, - encode, } from "near-sdk-js"; @NearBindgen({ requireInit: true }) @@ -210,7 +209,7 @@ export class FungibleToken { near.promiseBatchActionFunctionCall( promise, "ft_on_transfer", - encode(JSON.stringify(params)), + JSON.stringify(params), 0, 30000000000000 ); diff --git a/examples/src/non-fungible-token.js b/examples/src/non-fungible-token.js index 3718ce040..e18b2bd12 100644 --- a/examples/src/non-fungible-token.js +++ b/examples/src/non-fungible-token.js @@ -7,7 +7,6 @@ import { LookupMap, bytes, assert, - str, } from "near-sdk-js"; class Token { @@ -78,14 +77,12 @@ export class NftContract { near.promiseBatchActionFunctionCall( promise, "nftOnTransfer", - bytes( JSON.stringify({ senderId: sender_id, previousOwnerId: old_owner_id, tokenId: token_id, msg: msg, - }) - ), + }), 0, 30000000000000 ); @@ -93,7 +90,7 @@ export class NftContract { promise, near.currentAccountId(), "_nftResolveTransfer", - bytes(JSON.stringify({ sender_id, receiver_id, token_id })), + JSON.stringify({ sender_id, receiver_id, token_id }), 0, 30000000000000 ); @@ -104,7 +101,7 @@ export class NftContract { near.log( `_nftResolveTransfer called, receiver_id ${receiver_id}, token_id ${token_id}` ); - const isTokenTransfered = JSON.parse(str(near.promiseResult(0))); + const isTokenTransfered = JSON.parse(near.promiseResult(0)); near.log( `${token_id} ${ isTokenTransfered ? "was transfered" : "was NOT transfered" diff --git a/examples/src/programmatic-update-after.ts b/examples/src/programmatic-update-after.ts index 8d3e05965..4a847c6ef 100644 --- a/examples/src/programmatic-update-after.ts +++ b/examples/src/programmatic-update-after.ts @@ -1,12 +1,4 @@ -import { - NearBindgen, - near, - initialize, - assert, - view, - bytes, - str, -} from "near-sdk-js"; +import { NearBindgen, near, initialize, assert, view } from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateAfter { @@ -15,7 +7,7 @@ export class ProgrammaticUpdateAfter { @initialize({ privateFunction: true }) init({ manager }: { manager: string }) { near.log(`Setting manager to be ${manager}`); - near.storageWrite(bytes("MANAGER"), bytes(manager)); + near.storageWrite("MANAGER", manager); } @view({}) // Method renamed and return "Hi" when greeting is "Hello" @@ -25,14 +17,14 @@ export class ProgrammaticUpdateAfter { } export function updateContract() { - const manager = str(near.storageRead(bytes("MANAGER"))); + const manager = near.storageRead("MANAGER"); assert( near.predecessorAccountId() === manager, "Only the manager can update the code" ); const promiseId = near.promiseBatchCreate(near.currentAccountId()); - near.promiseBatchActionDeployContract(promiseId, near.input()); + near.promiseBatchActionDeployContract(promiseId, near.inputRaw()); return near.promiseReturn(promiseId); } diff --git a/examples/src/programmatic-update-before.ts b/examples/src/programmatic-update-before.ts index 54993d80e..190ac8d38 100644 --- a/examples/src/programmatic-update-before.ts +++ b/examples/src/programmatic-update-before.ts @@ -1,12 +1,4 @@ -import { - NearBindgen, - near, - initialize, - assert, - view, - bytes, - str, -} from "near-sdk-js"; +import { NearBindgen, near, initialize, assert, view } from "near-sdk-js"; @NearBindgen({ requireInit: true }) export class ProgrammaticUpdateBefore { @@ -15,7 +7,7 @@ export class ProgrammaticUpdateBefore { @initialize({ privateFunction: true }) init({ manager }: { manager: string }) { near.log(`Setting manager to be ${manager}`); - near.storageWrite(bytes("MANAGER"), bytes(manager)); + near.storageWrite("MANAGER", manager); } @view({}) // This method will be renamed after update and will return "Hi" if greeting is "Hello" @@ -25,14 +17,14 @@ export class ProgrammaticUpdateBefore { } export function updateContract() { - const manager = str(near.storageRead(bytes("MANAGER"))); + const manager = near.storageRead("MANAGER"); assert( near.predecessorAccountId() === manager, "Only the manager can update the code" ); const promiseId = near.promiseBatchCreate(near.currentAccountId()); - near.promiseBatchActionDeployContract(promiseId, near.input()); + near.promiseBatchActionDeployContract(promiseId, near.inputRaw()); return near.promiseReturn(promiseId); } diff --git a/examples/src/standard-nft/my-nft.ts b/examples/src/standard-nft/my-nft.ts index 2b0d66f13..1424adb89 100644 --- a/examples/src/standard-nft/my-nft.ts +++ b/examples/src/standard-nft/my-nft.ts @@ -32,26 +32,26 @@ import { NonFungibleTokenEnumeration } from "near-contract-standards/lib/non_fun class StorageKey {} class StorageKeyNonFungibleToken extends StorageKey implements IntoStorageKey { - into_storage_key(): Uint8Array { - return bytes("NFT_"); + into_storage_key(): string { + return "NFT_"; } } class StorageKeyTokenMetadata extends StorageKey implements IntoStorageKey { - into_storage_key(): Uint8Array { - return bytes("TOKEN_METADATA_"); + into_storage_key(): string { + return "TOKEN_METADATA_"; } } class StorageKeyTokenEnumeration extends StorageKey implements IntoStorageKey { - into_storage_key(): Uint8Array { - return bytes("TOKEN_ENUMERATION_"); + into_storage_key(): string { + return "TOKEN_ENUMERATION_"; } } class StorageKeyApproval extends StorageKey implements IntoStorageKey { - into_storage_key(): Uint8Array { - return bytes("APPROVAL1_"); + into_storage_key(): string { + return "APPROVAL1_"; } } diff --git a/examples/src/standard-nft/test-approval-receiver.ts b/examples/src/standard-nft/test-approval-receiver.ts index 9216cc437..30671cc0d 100644 --- a/examples/src/standard-nft/test-approval-receiver.ts +++ b/examples/src/standard-nft/test-approval-receiver.ts @@ -55,7 +55,7 @@ export class ApprovalReceiver default: { const prepaid_gas = near.prepaidGas(); const account_id = near.currentAccountId(); - return NearPromise.new(account_id).functionCall( + return NearPromise.new(account_id).functionCallRaw( "ok_go", serialize({ msg }), 0n, diff --git a/examples/src/standard-nft/test-token-receiver.ts b/examples/src/standard-nft/test-token-receiver.ts index a75a8c5cd..39e27bf58 100644 --- a/examples/src/standard-nft/test-token-receiver.ts +++ b/examples/src/standard-nft/test-token-receiver.ts @@ -63,7 +63,7 @@ export class TokenReceiver case "return-it-later": { const prepaid_gas = near.prepaidGas(); const account_id = near.currentAccountId(); - return NearPromise.new(account_id).functionCall( + return NearPromise.new(account_id).functionCallRaw( "ok_go", serialize({ return_it: true }), 0n, @@ -75,7 +75,7 @@ export class TokenReceiver case "keep-it-later": { const prepaid_gas = near.prepaidGas(); const account_id = near.currentAccountId(); - return NearPromise.new(account_id).functionCall( + return NearPromise.new(account_id).functionCallRaw( "ok_go", serialize({ return_it: false }), 0n, diff --git a/packages/near-contract-standards/lib/non_fungible_token/impl.d.ts b/packages/near-contract-standards/lib/non_fungible_token/impl.d.ts index b5f45fa48..a06a488cf 100644 --- a/packages/near-contract-standards/lib/non_fungible_token/impl.d.ts +++ b/packages/near-contract-standards/lib/non_fungible_token/impl.d.ts @@ -97,10 +97,10 @@ export type StorageKey = TokensPerOwner | TokenPerOwnerInner; export declare class TokensPerOwner implements IntoStorageKey { account_hash: Uint8Array; constructor(account_hash: Uint8Array); - into_storage_key(): Uint8Array; + into_storage_key(): string; } export declare class TokenPerOwnerInner implements IntoStorageKey { account_id_hash: Uint8Array; constructor(account_id_hash: Uint8Array); - into_storage_key(): Uint8Array; + into_storage_key(): string; } diff --git a/packages/near-contract-standards/lib/non_fungible_token/impl.js b/packages/near-contract-standards/lib/non_fungible_token/impl.js index 7d8293d9b..382b33f86 100644 --- a/packages/near-contract-standards/lib/non_fungible_token/impl.js +++ b/packages/near-contract-standards/lib/non_fungible_token/impl.js @@ -1,4 +1,4 @@ -import { UnorderedMap, LookupMap, near, UnorderedSet, assert, NearPromise, bytes, serialize, str, concat, } from "near-sdk-js"; +import { UnorderedMap, LookupMap, near, UnorderedSet, assert, NearPromise, bytes, serialize, str, } from "near-sdk-js"; import { TokenMetadata } from "./metadata"; import { refund_storage_deposit, refund_deposit, refund_deposit_to_account, assert_at_least_one_yocto, assert_one_yocto, } from "./utils"; import { NftMint, NftTransfer } from "./events"; @@ -114,7 +114,7 @@ export class NonFungibleToken { const storage_used = new_approved_account_ids_size - old_approved_account_ids_size; refund_deposit(BigInt(storage_used)); if (msg) { - return NearPromise.new(account_id).functionCall("nft_on_approve", serialize({ token_id, owner_id, approval_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_APPROVE); + return NearPromise.new(account_id).functionCallRaw("nft_on_approve", serialize({ token_id, owner_id, approval_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_APPROVE); } return null; } @@ -182,8 +182,8 @@ export class NonFungibleToken { let next_approval_id_by_id; if (approval_prefix) { const prefix = approval_prefix.into_storage_key(); - approvals_by_id = new LookupMap(str(prefix)); - next_approval_id_by_id = new LookupMap(str(prefix) + "n"); + approvals_by_id = new LookupMap(prefix); + next_approval_id_by_id = new LookupMap(prefix + "n"); } else { approvals_by_id = null; @@ -191,12 +191,12 @@ export class NonFungibleToken { } this.owner_id = owner_id; this.extra_storage_in_bytes_per_token = 0n; - this.owner_by_id = new UnorderedMap(str(owner_by_id_prefix.into_storage_key())); + this.owner_by_id = new UnorderedMap(owner_by_id_prefix.into_storage_key()); this.token_metadata_by_id = token_metadata_prefix - ? new LookupMap(str(token_metadata_prefix.into_storage_key())) + ? new LookupMap(token_metadata_prefix.into_storage_key()) : null; this.tokens_per_owner = enumeration_prefix - ? new LookupMap(str(enumeration_prefix.into_storage_key())) + ? new LookupMap(enumeration_prefix.into_storage_key()) : null; this.approvals_by_id = approvals_by_id; this.next_approval_id_by_id = next_approval_id_by_id; @@ -231,7 +231,7 @@ export class NonFungibleToken { this.token_metadata_by_id.set(tmp_token_id, new TokenMetadata(repeat("a", 64), repeat("a", 64), repeat("a", 64), repeat("a", 64), 1n, null, null, null, null, null, null, null)); } if (this.tokens_per_owner) { - const u = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(tmp_owner_id))).into_storage_key())); + const u = new UnorderedSet(new TokensPerOwner(near.sha256(bytes(tmp_owner_id))).into_storage_key()); u.set(tmp_token_id); this.tokens_per_owner.set(tmp_owner_id, u); } @@ -284,7 +284,7 @@ export class NonFungibleToken { reconstructor: UnorderedSet.reconstruct, }); if (receiver_tokens_set === null) { - receiver_tokens_set = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(to))).into_storage_key())); + receiver_tokens_set = new UnorderedSet(new TokensPerOwner(near.sha256(bytes(to))).into_storage_key()); } receiver_tokens_set.set(token_id); this.tokens_per_owner.set(to, receiver_tokens_set); @@ -343,7 +343,7 @@ export class NonFungibleToken { reconstructor: UnorderedSet.reconstruct, }); if (token_ids === null) { - token_ids = new UnorderedSet(str(new TokensPerOwner(near.sha256(bytes(owner_id))).into_storage_key())); + token_ids = new UnorderedSet(new TokensPerOwner(near.sha256(bytes(owner_id))).into_storage_key()); } token_ids.set(token_id); this.tokens_per_owner.set(owner_id, token_ids); @@ -366,13 +366,13 @@ export class NonFungibleToken { const sender_id = near.predecessorAccountId(); const [previous_owner_id, approved_account_ids] = this.internal_transfer(sender_id, receiver_id, token_id, approval_id, memo); const promise = NearPromise.new(receiver_id) - .functionCall("nft_on_transfer", bytes(JSON.stringify({ sender_id, previous_owner_id, token_id, msg })), 0n, near.prepaidGas() - GAS_FOR_NFT_TRANSFER_CALL) - .then(NearPromise.new(near.currentAccountId()).functionCall("nft_resolve_transfer", bytes(JSON.stringify({ + .functionCall("nft_on_transfer", JSON.stringify({ sender_id, previous_owner_id, token_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_TRANSFER_CALL) + .then(NearPromise.new(near.currentAccountId()).functionCall("nft_resolve_transfer", JSON.stringify({ previous_owner_id, receiver_id, token_id, approved_account_ids, - })), 0n, GAS_FOR_RESOLVE_TRANSFER)); + }), 0n, GAS_FOR_RESOLVE_TRANSFER)); return promise; } nft_token({ token_id }) { @@ -390,7 +390,7 @@ export class NonFungibleToken { let must_revert = false; let p; try { - p = str(near.promiseResult(0)); + p = near.promiseResult(0); } catch (e) { if (e.message.includes("Not Ready")) { @@ -448,7 +448,7 @@ export class TokensPerOwner { this.account_hash = account_hash; } into_storage_key() { - return concat(bytes("\x00"), this.account_hash); + return "\x00" + str(this.account_hash); } } export class TokenPerOwnerInner { @@ -456,6 +456,6 @@ export class TokenPerOwnerInner { this.account_id_hash = account_id_hash; } into_storage_key() { - return concat(bytes("\x01"), this.account_id_hash); + return "\x01" + str(this.account_id_hash); } } diff --git a/packages/near-contract-standards/lib/non_fungible_token/utils.d.ts b/packages/near-contract-standards/lib/non_fungible_token/utils.d.ts index 624bea9b0..f04ed0ae5 100644 --- a/packages/near-contract-standards/lib/non_fungible_token/utils.d.ts +++ b/packages/near-contract-standards/lib/non_fungible_token/utils.d.ts @@ -10,5 +10,5 @@ export declare function assert_at_least_one_yocto(): void; export declare function assert_one_yocto(): void; export type Option = T | null; export interface IntoStorageKey { - into_storage_key(): Uint8Array; + into_storage_key(): string; } diff --git a/packages/near-contract-standards/src/non_fungible_token/impl.ts b/packages/near-contract-standards/src/non_fungible_token/impl.ts index 300e069bf..b166d0127 100644 --- a/packages/near-contract-standards/src/non_fungible_token/impl.ts +++ b/packages/near-contract-standards/src/non_fungible_token/impl.ts @@ -9,7 +9,6 @@ import { bytes, serialize, str, - concat, } from "near-sdk-js"; import { TokenMetadata } from "./metadata"; import { @@ -213,7 +212,7 @@ export class NonFungibleToken refund_deposit(BigInt(storage_used)); if (msg) { - return NearPromise.new(account_id).functionCall( + return NearPromise.new(account_id).functionCallRaw( "nft_on_approve", serialize({ token_id, owner_id, approval_id, msg }), 0n, @@ -332,8 +331,8 @@ export class NonFungibleToken let next_approval_id_by_id: Option>; if (approval_prefix) { const prefix = approval_prefix.into_storage_key(); - approvals_by_id = new LookupMap(str(prefix)); - next_approval_id_by_id = new LookupMap(str(prefix) + "n"); + approvals_by_id = new LookupMap(prefix); + next_approval_id_by_id = new LookupMap(prefix + "n"); } else { approvals_by_id = null; next_approval_id_by_id = null; @@ -342,13 +341,13 @@ export class NonFungibleToken this.owner_id = owner_id; this.extra_storage_in_bytes_per_token = 0n; this.owner_by_id = new UnorderedMap( - str(owner_by_id_prefix.into_storage_key()) + owner_by_id_prefix.into_storage_key() ); this.token_metadata_by_id = token_metadata_prefix - ? new LookupMap(str(token_metadata_prefix.into_storage_key())) + ? new LookupMap(token_metadata_prefix.into_storage_key()) : null; this.tokens_per_owner = enumeration_prefix - ? new LookupMap(str(enumeration_prefix.into_storage_key())) + ? new LookupMap(enumeration_prefix.into_storage_key()) : null; this.approvals_by_id = approvals_by_id; this.next_approval_id_by_id = next_approval_id_by_id; @@ -407,11 +406,9 @@ export class NonFungibleToken } if (this.tokens_per_owner) { const u = new UnorderedSet( - str( new TokensPerOwner( near.sha256(bytes(tmp_owner_id)) ).into_storage_key() - ) ); u.set(tmp_token_id); this.tokens_per_owner.set(tmp_owner_id, u); @@ -474,7 +471,7 @@ export class NonFungibleToken }); if (receiver_tokens_set === null) { receiver_tokens_set = new UnorderedSet( - str(new TokensPerOwner(near.sha256(bytes(to))).into_storage_key()) + new TokensPerOwner(near.sha256(bytes(to))).into_storage_key() ); } receiver_tokens_set.set(token_id); @@ -584,9 +581,7 @@ export class NonFungibleToken }); if (token_ids === null) { token_ids = new UnorderedSet( - str( new TokensPerOwner(near.sha256(bytes(owner_id))).into_storage_key() - ) ); } token_ids.set(token_id); @@ -647,21 +642,19 @@ export class NonFungibleToken const promise = NearPromise.new(receiver_id) .functionCall( "nft_on_transfer", - bytes(JSON.stringify({ sender_id, previous_owner_id, token_id, msg })), + JSON.stringify({ sender_id, previous_owner_id, token_id, msg }), 0n, near.prepaidGas() - GAS_FOR_NFT_TRANSFER_CALL ) .then( NearPromise.new(near.currentAccountId()).functionCall( "nft_resolve_transfer", - bytes( JSON.stringify({ previous_owner_id, receiver_id, token_id, approved_account_ids, - }) - ), + }), 0n, GAS_FOR_RESOLVE_TRANSFER ) @@ -697,7 +690,7 @@ export class NonFungibleToken let must_revert = false; let p: string; try { - p = str(near.promiseResult(0)); + p = near.promiseResult(0); } catch (e) { if (e.message.includes("Not Ready")) { throw new Error(); @@ -767,15 +760,15 @@ export type StorageKey = TokensPerOwner | TokenPerOwnerInner; export class TokensPerOwner implements IntoStorageKey { constructor(public account_hash: Uint8Array) {} - into_storage_key(): Uint8Array { - return concat(bytes("\x00"), this.account_hash); + into_storage_key(): string { + return "\x00" + str(this.account_hash); } } export class TokenPerOwnerInner implements IntoStorageKey { constructor(public account_id_hash: Uint8Array) {} - into_storage_key(): Uint8Array { - return concat(bytes("\x01"), this.account_id_hash); + into_storage_key(): string { + return "\x01" + str(this.account_id_hash); } } diff --git a/packages/near-contract-standards/src/non_fungible_token/utils.ts b/packages/near-contract-standards/src/non_fungible_token/utils.ts index 9dc60a1fa..b8ba08cec 100644 --- a/packages/near-contract-standards/src/non_fungible_token/utils.ts +++ b/packages/near-contract-standards/src/non_fungible_token/utils.ts @@ -60,5 +60,5 @@ export function assert_one_yocto(): void { export type Option = T | null; export interface IntoStorageKey { - into_storage_key(): Uint8Array; + into_storage_key(): string; } diff --git a/packages/near-sdk-js/lib/api.d.ts b/packages/near-sdk-js/lib/api.d.ts index d905af59d..595388fbc 100644 --- a/packages/near-sdk-js/lib/api.d.ts +++ b/packages/near-sdk-js/lib/api.d.ts @@ -67,17 +67,33 @@ export declare function accountLockedBalance(): bigint; * * @param key - The key to read from storage. */ -export declare function storageRead(key: Uint8Array): Uint8Array | null; +export declare function storageReadRaw(key: Uint8Array): Uint8Array | null; +/** + * Reads the utf-8 string value from NEAR storage that is stored under the provided key. + * + * @param key - The utf-8 string key to read from storage. + */ +export declare function storageRead(key: string): string | null; /** * Checks for the existance of a value under the provided key in NEAR storage. * * @param key - The key to check for in storage. */ -export declare function storageHasKey(key: Uint8Array): boolean; +export declare function storageHasKeyRaw(key: Uint8Array): boolean; +/** + * Checks for the existance of a value under the provided utf-8 string key in NEAR storage. + * + * @param key - The utf-8 string key to check for in storage. + */ +export declare function storageHasKey(key: string): boolean; /** * Get the last written or removed value from NEAR storage. */ -export declare function storageGetEvicted(): Uint8Array; +export declare function storageGetEvictedRaw(): Uint8Array; +/** + * Get the last written or removed value from NEAR storage as utf-8 string. + */ +export declare function storageGetEvicted(): string; /** * Returns the current accounts NEAR storage usage. */ @@ -88,13 +104,26 @@ export declare function storageUsage(): bigint; * @param key - The key under which to store the value. * @param value - The value to store. */ -export declare function storageWrite(key: Uint8Array, value: Uint8Array): boolean; +export declare function storageWriteRaw(key: Uint8Array, value: Uint8Array): boolean; +/** + * Writes the provided utf-8 string to NEAR storage under the provided key. + * + * @param key - The utf-8 string key under which to store the value. + * @param value - The utf-8 string value to store. + */ +export declare function storageWrite(key: string, value: string): boolean; /** * Removes the value of the provided key from NEAR storage. * * @param key - The key to be removed. */ -export declare function storageRemove(key: Uint8Array): boolean; +export declare function storageRemoveRaw(key: Uint8Array): boolean; +/** + * Removes the value of the provided utf-8 string key from NEAR storage. + * + * @param key - The utf-8 string key to be removed. + */ +export declare function storageRemove(key: string): boolean; /** * Returns the cost of storing 0 Byte on NEAR storage. */ @@ -102,13 +131,23 @@ export declare function storageByteCost(): bigint; /** * Returns the arguments passed to the current smart contract call. */ -export declare function input(): Uint8Array; +export declare function inputRaw(): Uint8Array; +/** + * Returns the arguments passed to the current smart contract call as utf-8 string. + */ +export declare function input(): string; /** * Returns the value from the NEAR WASM virtual machine. * * @param value - The value to return. */ -export declare function valueReturn(value: Uint8Array): void; +export declare function valueReturnRaw(value: Uint8Array): void; +/** + * Returns the utf-8 string value from the NEAR WASM virtual machine. + * + * @param value - The utf-8 string value to return. + */ +export declare function valueReturn(value: string): void; /** * Returns a random string of bytes. */ @@ -122,7 +161,17 @@ export declare function randomSeed(): Uint8Array; * @param amount - The amount of NEAR attached to the call. * @param gas - The amount of Gas attached to the call. */ -export declare function promiseCreate(accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; +export declare function promiseCreateRaw(accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; +/** + * Create a NEAR promise call to a contract on the blockchain. + * + * @param accountId - The account ID of the target contract. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR attached to the call. + * @param gas - The amount of Gas attached to the call. + */ +export declare function promiseCreate(accountId: string, methodName: string, args: string, amount: NearAmount, gas: NearAmount): PromiseIndex; /** * Attach a callback NEAR promise to be executed after a provided promise. * @@ -133,7 +182,18 @@ export declare function promiseCreate(accountId: string, methodName: string, arg * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export declare function promiseThen(promiseIndex: PromiseIndex, accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; +export declare function promiseThenRaw(promiseIndex: PromiseIndex, accountId: string, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): PromiseIndex; +/** + * Attach a callback NEAR promise to be executed after a provided promise. + * + * @param promiseIndex - The promise after which to call the callback. + * @param accountId - The account ID of the contract to perform the callback on. + * @param methodName - The name of the method to call. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export declare function promiseThen(promiseIndex: PromiseIndex, accountId: string, methodName: string, args: string, amount: NearAmount, gas: NearAmount): PromiseIndex; /** * Join an arbitrary array of NEAR promises. * @@ -175,7 +235,17 @@ export declare function promiseBatchActionDeployContract(promiseIndex: PromiseIn * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export declare function promiseBatchActionFunctionCall(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): void; +export declare function promiseBatchActionFunctionCallRaw(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount): void; +/** + * Attach a function call promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export declare function promiseBatchActionFunctionCall(promiseIndex: PromiseIndex, methodName: string, args: string, amount: NearAmount, gas: NearAmount): void; /** * Attach a transfer promise action to the NEAR promise index with the provided promise index. * @@ -234,7 +304,18 @@ export declare function promiseBatchActionDeleteAccount(promiseIndex: PromiseInd * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ -export declare function promiseBatchActionFunctionCallWeight(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount, weight: GasWeight): void; +export declare function promiseBatchActionFunctionCallWeightRaw(promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, amount: NearAmount, gas: NearAmount, weight: GasWeight): void; +/** + * Attach a function call with weight promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call with weight action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ +export declare function promiseBatchActionFunctionCallWeight(promiseIndex: PromiseIndex, methodName: string, args: string, amount: NearAmount, gas: NearAmount, weight: GasWeight): void; /** * The number of promise results available. */ @@ -244,7 +325,13 @@ export declare function promiseResultsCount(): bigint; * * @param promiseIndex - The index of the promise to return the result for. */ -export declare function promiseResult(promiseIndex: PromiseIndex): Uint8Array; +export declare function promiseResultRaw(promiseIndex: PromiseIndex): Uint8Array; +/** + * Returns the result of the NEAR promise for the passed promise index as utf-8 string + * + * @param promiseIndex - The index of the promise to return the result for. + */ +export declare function promiseResult(promiseIndex: PromiseIndex): string; /** * Executes the promise in the NEAR WASM virtual machine. * diff --git a/packages/near-sdk-js/lib/api.js b/packages/near-sdk-js/lib/api.js index 5ac9b265d..169f4732a 100644 --- a/packages/near-sdk-js/lib/api.js +++ b/packages/near-sdk-js/lib/api.js @@ -1,4 +1,4 @@ -import { assert, str } from "./utils"; +import { assert, str, encode, decode, } from "./utils"; import { PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; const EVICTED_REGISTER = U64_MAX - 1n; @@ -110,27 +110,53 @@ export function accountLockedBalance() { * * @param key - The key to read from storage. */ -export function storageRead(key) { +export function storageReadRaw(key) { const returnValue = env.storage_read(key, 0); if (returnValue !== 1n) { return null; } return env.read_register(0); } +/** + * Reads the utf-8 string value from NEAR storage that is stored under the provided key. + * + * @param key - The utf-8 string key to read from storage. + */ +export function storageRead(key) { + const ret = storageReadRaw(encode(key)); + if (ret !== null) { + return decode(ret); + } + return null; +} /** * Checks for the existance of a value under the provided key in NEAR storage. * * @param key - The key to check for in storage. */ -export function storageHasKey(key) { +export function storageHasKeyRaw(key) { return env.storage_has_key(key) === 1n; } +/** + * Checks for the existance of a value under the provided utf-8 string key in NEAR storage. + * + * @param key - The utf-8 string key to check for in storage. + */ +export function storageHasKey(key) { + return storageHasKeyRaw(encode(key)); +} /** * Get the last written or removed value from NEAR storage. */ -export function storageGetEvicted() { +export function storageGetEvictedRaw() { return env.read_register(EVICTED_REGISTER); } +/** + * Get the last written or removed value from NEAR storage as utf-8 string. + */ +export function storageGetEvicted() { + return decode(storageGetEvictedRaw()); +} /** * Returns the current accounts NEAR storage usage. */ @@ -143,17 +169,34 @@ export function storageUsage() { * @param key - The key under which to store the value. * @param value - The value to store. */ -export function storageWrite(key, value) { +export function storageWriteRaw(key, value) { return env.storage_write(key, value, EVICTED_REGISTER) === 1n; } +/** + * Writes the provided utf-8 string to NEAR storage under the provided key. + * + * @param key - The utf-8 string key under which to store the value. + * @param value - The utf-8 string value to store. + */ +export function storageWrite(key, value) { + return storageWriteRaw(encode(key), encode(value)); +} /** * Removes the value of the provided key from NEAR storage. * * @param key - The key to be removed. */ -export function storageRemove(key) { +export function storageRemoveRaw(key) { return env.storage_remove(key, EVICTED_REGISTER) === 1n; } +/** + * Removes the value of the provided utf-8 string key from NEAR storage. + * + * @param key - The utf-8 string key to be removed. + */ +export function storageRemove(key) { + return storageRemoveRaw(encode(key)); +} /** * Returns the cost of storing 0 Byte on NEAR storage. */ @@ -163,18 +206,32 @@ export function storageByteCost() { /** * Returns the arguments passed to the current smart contract call. */ -export function input() { +export function inputRaw() { env.input(0); return env.read_register(0); } +/** + * Returns the arguments passed to the current smart contract call as utf-8 string. + */ +export function input() { + return decode(inputRaw()); +} /** * Returns the value from the NEAR WASM virtual machine. * * @param value - The value to return. */ -export function valueReturn(value) { +export function valueReturnRaw(value) { env.value_return(value); } +/** + * Returns the utf-8 string value from the NEAR WASM virtual machine. + * + * @param value - The utf-8 string value to return. + */ +export function valueReturn(value) { + valueReturnRaw(encode(value)); +} /** * Returns a random string of bytes. */ @@ -191,9 +248,21 @@ export function randomSeed() { * @param amount - The amount of NEAR attached to the call. * @param gas - The amount of Gas attached to the call. */ -export function promiseCreate(accountId, methodName, args, amount, gas) { +export function promiseCreateRaw(accountId, methodName, args, amount, gas) { return env.promise_create(accountId, methodName, args, amount, gas); } +/** + * Create a NEAR promise call to a contract on the blockchain. + * + * @param accountId - The account ID of the target contract. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR attached to the call. + * @param gas - The amount of Gas attached to the call. + */ +export function promiseCreate(accountId, methodName, args, amount, gas) { + return promiseCreateRaw(accountId, methodName, encode(args), amount, gas); +} /** * Attach a callback NEAR promise to be executed after a provided promise. * @@ -204,9 +273,22 @@ export function promiseCreate(accountId, methodName, args, amount, gas) { * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export function promiseThen(promiseIndex, accountId, methodName, args, amount, gas) { +export function promiseThenRaw(promiseIndex, accountId, methodName, args, amount, gas) { return env.promise_then(promiseIndex, accountId, methodName, args, amount, gas); } +/** + * Attach a callback NEAR promise to be executed after a provided promise. + * + * @param promiseIndex - The promise after which to call the callback. + * @param accountId - The account ID of the contract to perform the callback on. + * @param methodName - The name of the method to call. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export function promiseThen(promiseIndex, accountId, methodName, args, amount, gas) { + return promiseThenRaw(promiseIndex, accountId, methodName, encode(args), amount, gas); +} /** * Join an arbitrary array of NEAR promises. * @@ -258,9 +340,21 @@ export function promiseBatchActionDeployContract(promiseIndex, code) { * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export function promiseBatchActionFunctionCall(promiseIndex, methodName, args, amount, gas) { +export function promiseBatchActionFunctionCallRaw(promiseIndex, methodName, args, amount, gas) { env.promise_batch_action_function_call(promiseIndex, methodName, args, amount, gas); } +/** + * Attach a function call promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export function promiseBatchActionFunctionCall(promiseIndex, methodName, args, amount, gas) { + promiseBatchActionFunctionCallRaw(promiseIndex, methodName, encode(args), amount, gas); +} /** * Attach a transfer promise action to the NEAR promise index with the provided promise index. * @@ -331,9 +425,22 @@ export function promiseBatchActionDeleteAccount(promiseIndex, beneficiaryId) { * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ -export function promiseBatchActionFunctionCallWeight(promiseIndex, methodName, args, amount, gas, weight) { +export function promiseBatchActionFunctionCallWeightRaw(promiseIndex, methodName, args, amount, gas, weight) { env.promise_batch_action_function_call_weight(promiseIndex, methodName, args, amount, gas, weight); } +/** + * Attach a function call with weight promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call with weight action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ +export function promiseBatchActionFunctionCallWeight(promiseIndex, methodName, args, amount, gas, weight) { + env.promise_batch_action_function_call_weight(promiseIndex, methodName, encode(args), amount, gas, weight); +} /** * The number of promise results available. */ @@ -345,7 +452,7 @@ export function promiseResultsCount() { * * @param promiseIndex - The index of the promise to return the result for. */ -export function promiseResult(promiseIndex) { +export function promiseResultRaw(promiseIndex) { const status = env.promise_result(promiseIndex, 0); assert(Number(status) === PromiseResult.Successful, `Promise result ${status == PromiseResult.Failed ? "Failed" @@ -354,6 +461,14 @@ export function promiseResult(promiseIndex) { : status}`); return env.read_register(0); } +/** + * Returns the result of the NEAR promise for the passed promise index as utf-8 string + * + * @param promiseIndex - The index of the promise to return the result for. + */ +export function promiseResult(promiseIndex) { + return decode(promiseResultRaw(promiseIndex)); +} /** * Executes the promise in the NEAR WASM virtual machine. * diff --git a/packages/near-sdk-js/lib/collections/lookup-map.js b/packages/near-sdk-js/lib/collections/lookup-map.js index e96bd69da..364049a67 100644 --- a/packages/near-sdk-js/lib/collections/lookup-map.js +++ b/packages/near-sdk-js/lib/collections/lookup-map.js @@ -17,7 +17,7 @@ export class LookupMap { */ containsKey(key) { const storageKey = this.keyPrefix + key; - return near.storageHasKey(encode(storageKey)); + return near.storageHasKey(storageKey); } /** * Get the data stored at the provided key. @@ -27,7 +27,7 @@ export class LookupMap { */ get(key, options) { const storageKey = this.keyPrefix + key; - const value = near.storageRead(encode(storageKey)); + const value = near.storageReadRaw(encode(storageKey)); return getValueWithOptions(value, options); } /** @@ -38,10 +38,10 @@ export class LookupMap { */ remove(key, options) { const storageKey = this.keyPrefix + key; - if (!near.storageRemove(encode(storageKey))) { + if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; } - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } /** @@ -54,10 +54,10 @@ export class LookupMap { set(key, newValue, options) { const storageKey = this.keyPrefix + key; const storageValue = serializeValueWithOptions(newValue, options); - if (!near.storageWrite(encode(storageKey), storageValue)) { + if (!near.storageWriteRaw(encode(storageKey), storageValue)) { return options?.defaultValue ?? null; } - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } /** diff --git a/packages/near-sdk-js/lib/collections/lookup-set.js b/packages/near-sdk-js/lib/collections/lookup-set.js index db157b148..b597f97b3 100644 --- a/packages/near-sdk-js/lib/collections/lookup-set.js +++ b/packages/near-sdk-js/lib/collections/lookup-set.js @@ -1,5 +1,5 @@ import * as near from "../api"; -import { serializeValueWithOptions, encode } from "../utils"; +import { serializeValueWithOptions } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. */ @@ -18,7 +18,7 @@ export class LookupSet { */ contains(key, options) { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return near.storageHasKey(encode(storageKey)); + return near.storageHasKey(storageKey); } /** * Returns true if the element was present in the set. @@ -28,7 +28,7 @@ export class LookupSet { */ remove(key, options) { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return near.storageRemove(encode(storageKey)); + return near.storageRemove(storageKey); } /** * If the set did not have this value present, `true` is returned. @@ -39,7 +39,7 @@ export class LookupSet { */ set(key, options) { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return !near.storageWrite(encode(storageKey), new Uint8Array()); + return !near.storageWrite(storageKey, ""); } /** * Extends the current collection with the passed in array of elements. diff --git a/packages/near-sdk-js/lib/collections/unordered-set.js b/packages/near-sdk-js/lib/collections/unordered-set.js index 1fce988a1..e5a3f5551 100644 --- a/packages/near-sdk-js/lib/collections/unordered-set.js +++ b/packages/near-sdk-js/lib/collections/unordered-set.js @@ -42,7 +42,7 @@ export class UnorderedSet { */ contains(element, options) { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - return near.storageHasKey(encode(indexLookup)); + return near.storageHasKey(indexLookup); } /** * If the set did not have this value present, `true` is returned. @@ -53,12 +53,12 @@ export class UnorderedSet { */ set(element, options) { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - if (near.storageRead(encode(indexLookup))) { + if (near.storageRead(indexLookup)) { return false; } const nextIndex = this.length; const nextIndexRaw = serializeIndex(nextIndex); - near.storageWrite(encode(indexLookup), nextIndexRaw); + near.storageWriteRaw(encode(indexLookup), nextIndexRaw); this.elements.push(element, options); return true; } @@ -70,14 +70,14 @@ export class UnorderedSet { */ remove(element, options) { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - const indexRaw = near.storageRead(encode(indexLookup)); + const indexRaw = near.storageReadRaw(encode(indexLookup)); if (!indexRaw) { return false; } // If there is only one element then swap remove simply removes it without // swapping with the last element. if (this.length === 1) { - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); return true; @@ -86,13 +86,13 @@ export class UnorderedSet { // element. const lastElement = this.elements.get(this.length - 1, options); assert(!!lastElement, ERR_INCONSISTENT_STATE); - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. if (lastElement !== element) { const lastLookupElement = this.elementIndexPrefix + serializeValueWithOptions(lastElement, options); - near.storageWrite(encode(lastLookupElement), indexRaw); + near.storageWriteRaw(encode(lastLookupElement), indexRaw); } const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); @@ -104,7 +104,7 @@ export class UnorderedSet { clear(options) { for (const element of this.elements) { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); } this.elements.clear(); } diff --git a/packages/near-sdk-js/lib/collections/vector.js b/packages/near-sdk-js/lib/collections/vector.js index 9a36183b4..79bc8b858 100644 --- a/packages/near-sdk-js/lib/collections/vector.js +++ b/packages/near-sdk-js/lib/collections/vector.js @@ -36,7 +36,7 @@ export class Vector { return options?.defaultValue ?? null; } const storageKey = indexToKey(this.prefix, index); - const value = near.storageRead(bytes(storageKey)); + const value = near.storageReadRaw(bytes(storageKey)); return getValueWithOptions(value, options); } /** @@ -54,8 +54,8 @@ export class Vector { } const key = indexToKey(this.prefix, index); const last = this.pop(options); - assert(near.storageWrite(bytes(key), serializeValueWithOptions(last, options)), ERR_INCONSISTENT_STATE); - const value = near.storageGetEvicted(); + assert(near.storageWriteRaw(bytes(key), serializeValueWithOptions(last, options)), ERR_INCONSISTENT_STATE); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } /** @@ -67,7 +67,7 @@ export class Vector { push(element, options) { const key = indexToKey(this.prefix, this.length); this.length += 1; - near.storageWrite(bytes(key), serializeValueWithOptions(element, options)); + near.storageWriteRaw(bytes(key), serializeValueWithOptions(element, options)); } /** * Removes and retrieves the element with the highest index. @@ -81,8 +81,8 @@ export class Vector { const lastIndex = this.length - 1; const lastKey = indexToKey(this.prefix, lastIndex); this.length -= 1; - assert(near.storageRemove(bytes(lastKey)), ERR_INCONSISTENT_STATE); - const value = near.storageGetEvicted(); + assert(near.storageRemoveRaw(bytes(lastKey)), ERR_INCONSISTENT_STATE); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } /** @@ -95,8 +95,8 @@ export class Vector { replace(index, element, options) { assert(index < this.length, ERR_INDEX_OUT_OF_BOUNDS); const key = indexToKey(this.prefix, index); - assert(near.storageWrite(bytes(key), serializeValueWithOptions(element, options)), ERR_INCONSISTENT_STATE); - const value = near.storageGetEvicted(); + assert(near.storageWriteRaw(bytes(key), serializeValueWithOptions(element, options)), ERR_INCONSISTENT_STATE); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } /** @@ -141,7 +141,7 @@ export class Vector { clear() { for (let index = 0; index < this.length; index++) { const key = indexToKey(this.prefix, index); - near.storageRemove(bytes(key)); + near.storageRemoveRaw(bytes(key)); } this.length = 0; } diff --git a/packages/near-sdk-js/lib/near-bindgen.js b/packages/near-sdk-js/lib/near-bindgen.js index c38597c7c..d5d8eb3af 100644 --- a/packages/near-sdk-js/lib/near-bindgen.js +++ b/packages/near-sdk-js/lib/near-bindgen.js @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize, bytes, encode, decode } from "./utils"; +import { deserialize, serialize, bytes, encode } from "./utils"; /** * Tells the SDK to use this function as the initialization function of the contract. * @@ -71,14 +71,14 @@ export function NearBindgen({ requireInit = false, serializer = serialize, deser return new target(); } static _getState() { - const rawState = near.storageRead(bytes("STATE")); + const rawState = near.storageReadRaw(bytes("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave) { - near.storageWrite(bytes("STATE"), this._serialize(objectToSave)); + near.storageWriteRaw(bytes("STATE"), this._serialize(objectToSave)); } static _getArgs() { - return JSON.parse(decode(near.input()) || "{}"); + return JSON.parse(near.input() || "{}"); } static _serialize(value, forReturn = false) { if (forReturn) { diff --git a/packages/near-sdk-js/lib/promise.d.ts b/packages/near-sdk-js/lib/promise.d.ts index aa47c2e27..8e4b62bca 100644 --- a/packages/near-sdk-js/lib/promise.d.ts +++ b/packages/near-sdk-js/lib/promise.d.ts @@ -39,6 +39,25 @@ export declare class DeployContract extends PromiseAction { * @extends {PromiseAction} */ export declare class FunctionCall extends PromiseAction { + functionName: string; + args: string; + amount: Balance; + gas: Gas; + /** + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ + constructor(functionName: string, args: string, amount: Balance, gas: Gas); + add(promiseIndex: PromiseIndex): void; +} +/** + * A function call raw promise action. + * + * @extends {PromiseAction} + */ +export declare class FunctionCallRaw extends PromiseAction { functionName: string; args: Uint8Array; amount: Balance; @@ -58,6 +77,27 @@ export declare class FunctionCall extends PromiseAction { * @extends {PromiseAction} */ export declare class FunctionCallWeight extends PromiseAction { + functionName: string; + args: string; + amount: Balance; + gas: Gas; + weight: GasWeight; + /** + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + constructor(functionName: string, args: string, amount: Balance, gas: Gas, weight: GasWeight); + add(promiseIndex: PromiseIndex): void; +} +/** + * A function call weight raw promise action. + * + * @extends {PromiseAction} + */ +export declare class FunctionCallWeightRaw extends PromiseAction { functionName: string; args: Uint8Array; amount: Balance; @@ -211,21 +251,40 @@ export declare class NearPromise { * Creates a function call promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ + functionCall(functionName: string, args: string, amount: Balance, gas: Gas): NearPromise; + /** + * Creates a function call raw promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ - functionCall(functionName: string, args: Uint8Array, amount: Balance, gas: Gas): NearPromise; + functionCallRaw(functionName: string, args: Uint8Array, amount: Balance, gas: Gas): NearPromise; /** * Creates a function call weight promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + functionCallWeight(functionName: string, args: string, amount: Balance, gas: Gas, weight: GasWeight): NearPromise; + /** + * Creates a function call weight raw promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ - functionCallWeight(functionName: string, args: Uint8Array, amount: Balance, gas: Gas, weight: GasWeight): NearPromise; + functionCallWeightRaw(functionName: string, args: Uint8Array, amount: Balance, gas: Gas, weight: GasWeight): NearPromise; /** * Creates a transfer promise action and adds it to the current promise. * diff --git a/packages/near-sdk-js/lib/promise.js b/packages/near-sdk-js/lib/promise.js index 186611789..1c7872bdc 100644 --- a/packages/near-sdk-js/lib/promise.js +++ b/packages/near-sdk-js/lib/promise.js @@ -40,7 +40,7 @@ export class DeployContract extends PromiseAction { export class FunctionCall extends PromiseAction { /** * @param functionName - The name of the function to be called. - * @param args - The arguments to be passed to the function. + * @param args - The utf-8 string arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ @@ -55,6 +55,29 @@ export class FunctionCall extends PromiseAction { near.promiseBatchActionFunctionCall(promiseIndex, this.functionName, this.args, this.amount, this.gas); } } +/** + * A function call raw promise action. + * + * @extends {PromiseAction} + */ +export class FunctionCallRaw extends PromiseAction { + /** + * @param functionName - The name of the function to be called. + * @param args - The arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ + constructor(functionName, args, amount, gas) { + super(); + this.functionName = functionName; + this.args = args; + this.amount = amount; + this.gas = gas; + } + add(promiseIndex) { + near.promiseBatchActionFunctionCallRaw(promiseIndex, this.functionName, this.args, this.amount, this.gas); + } +} /** * A function call weight promise action. * @@ -63,7 +86,7 @@ export class FunctionCall extends PromiseAction { export class FunctionCallWeight extends PromiseAction { /** * @param functionName - The name of the function to be called. - * @param args - The arguments to be passed to the function. + * @param args - The utf-8 string arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. @@ -80,6 +103,31 @@ export class FunctionCallWeight extends PromiseAction { near.promiseBatchActionFunctionCallWeight(promiseIndex, this.functionName, this.args, this.amount, this.gas, this.weight); } } +/** + * A function call weight raw promise action. + * + * @extends {PromiseAction} + */ +export class FunctionCallWeightRaw extends PromiseAction { + /** + * @param functionName - The name of the function to be called. + * @param args - The arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + constructor(functionName, args, amount, gas, weight) { + super(); + this.functionName = functionName; + this.args = args; + this.amount = amount; + this.gas = gas; + this.weight = weight; + } + add(promiseIndex) { + near.promiseBatchActionFunctionCallWeightRaw(promiseIndex, this.functionName, this.args, this.amount, this.gas, this.weight); + } +} /** * A transfer promise action. * @@ -274,7 +322,7 @@ export class NearPromise { * Creates a function call promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. - * @param args - The arguments to be passed to the function. + * @param args - The utf-8 string arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ @@ -282,17 +330,40 @@ export class NearPromise { return this.addAction(new FunctionCall(functionName, args, amount, gas)); } /** - * Creates a function call weight promise action and adds it to the current promise. + * Creates a function call raw promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. + */ + functionCallRaw(functionName, args, amount, gas) { + return this.addAction(new FunctionCallRaw(functionName, args, amount, gas)); + } + /** + * Creates a function call weight promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ functionCallWeight(functionName, args, amount, gas, weight) { return this.addAction(new FunctionCallWeight(functionName, args, amount, gas, weight)); } + /** + * Creates a function call weight raw promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. + * @param args - The arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + functionCallWeightRaw(functionName, args, amount, gas, weight) { + return this.addAction(new FunctionCallWeightRaw(functionName, args, amount, gas, weight)); + } /** * Creates a transfer promise action and adds it to the current promise. * diff --git a/packages/near-sdk-js/src/api.ts b/packages/near-sdk-js/src/api.ts index 8a2e9e0b7..29479f940 100644 --- a/packages/near-sdk-js/src/api.ts +++ b/packages/near-sdk-js/src/api.ts @@ -1,4 +1,12 @@ -import { assert, NearAmount, PromiseIndex, Register, str } from "./utils"; +import { + assert, + NearAmount, + PromiseIndex, + Register, + str, + encode, + decode, +} from "./utils"; import { GasWeight, PromiseResult } from "./types"; const U64_MAX = 2n ** 64n - 1n; @@ -271,7 +279,7 @@ export function accountLockedBalance(): bigint { * * @param key - The key to read from storage. */ -export function storageRead(key: Uint8Array): Uint8Array | null { +export function storageReadRaw(key: Uint8Array): Uint8Array | null { const returnValue = env.storage_read(key, 0); if (returnValue !== 1n) { @@ -281,22 +289,51 @@ export function storageRead(key: Uint8Array): Uint8Array | null { return env.read_register(0); } +/** + * Reads the utf-8 string value from NEAR storage that is stored under the provided key. + * + * @param key - The utf-8 string key to read from storage. + */ +export function storageRead(key: string): string | null { + const ret = storageReadRaw(encode(key)); + if (ret !== null) { + return decode(ret); + } + return null; +} + /** * Checks for the existance of a value under the provided key in NEAR storage. * * @param key - The key to check for in storage. */ -export function storageHasKey(key: Uint8Array): boolean { +export function storageHasKeyRaw(key: Uint8Array): boolean { return env.storage_has_key(key) === 1n; } +/** + * Checks for the existance of a value under the provided utf-8 string key in NEAR storage. + * + * @param key - The utf-8 string key to check for in storage. + */ +export function storageHasKey(key: string): boolean { + return storageHasKeyRaw(encode(key)); +} + /** * Get the last written or removed value from NEAR storage. */ -export function storageGetEvicted(): Uint8Array { +export function storageGetEvictedRaw(): Uint8Array { return env.read_register(EVICTED_REGISTER); } +/** + * Get the last written or removed value from NEAR storage as utf-8 string. + */ +export function storageGetEvicted(): string { + return decode(storageGetEvictedRaw()); +} + /** * Returns the current accounts NEAR storage usage. */ @@ -310,19 +347,38 @@ export function storageUsage(): bigint { * @param key - The key under which to store the value. * @param value - The value to store. */ -export function storageWrite(key: Uint8Array, value: Uint8Array): boolean { +export function storageWriteRaw(key: Uint8Array, value: Uint8Array): boolean { return env.storage_write(key, value, EVICTED_REGISTER) === 1n; } +/** + * Writes the provided utf-8 string to NEAR storage under the provided key. + * + * @param key - The utf-8 string key under which to store the value. + * @param value - The utf-8 string value to store. + */ +export function storageWrite(key: string, value: string): boolean { + return storageWriteRaw(encode(key), encode(value)); +} + /** * Removes the value of the provided key from NEAR storage. * * @param key - The key to be removed. */ -export function storageRemove(key: Uint8Array): boolean { +export function storageRemoveRaw(key: Uint8Array): boolean { return env.storage_remove(key, EVICTED_REGISTER) === 1n; } +/** + * Removes the value of the provided utf-8 string key from NEAR storage. + * + * @param key - The utf-8 string key to be removed. + */ +export function storageRemove(key: string): boolean { + return storageRemoveRaw(encode(key)); +} + /** * Returns the cost of storing 0 Byte on NEAR storage. */ @@ -333,20 +389,36 @@ export function storageByteCost(): bigint { /** * Returns the arguments passed to the current smart contract call. */ -export function input(): Uint8Array { +export function inputRaw(): Uint8Array { env.input(0); return env.read_register(0); } +/** + * Returns the arguments passed to the current smart contract call as utf-8 string. + */ +export function input(): string { + return decode(inputRaw()); +} + /** * Returns the value from the NEAR WASM virtual machine. * * @param value - The value to return. */ -export function valueReturn(value: Uint8Array): void { +export function valueReturnRaw(value: Uint8Array): void { env.value_return(value); } +/** + * Returns the utf-8 string value from the NEAR WASM virtual machine. + * + * @param value - The utf-8 string value to return. + */ +export function valueReturn(value: string): void { + valueReturnRaw(encode(value)); +} + /** * Returns a random string of bytes. */ @@ -364,7 +436,7 @@ export function randomSeed(): Uint8Array { * @param amount - The amount of NEAR attached to the call. * @param gas - The amount of Gas attached to the call. */ -export function promiseCreate( +export function promiseCreateRaw( accountId: string, methodName: string, args: Uint8Array, @@ -380,6 +452,25 @@ export function promiseCreate( ) as unknown as PromiseIndex; } +/** + * Create a NEAR promise call to a contract on the blockchain. + * + * @param accountId - The account ID of the target contract. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR attached to the call. + * @param gas - The amount of Gas attached to the call. + */ +export function promiseCreate( + accountId: string, + methodName: string, + args: string, + amount: NearAmount, + gas: NearAmount +): PromiseIndex { + return promiseCreateRaw(accountId, methodName, encode(args), amount, gas); +} + /** * Attach a callback NEAR promise to be executed after a provided promise. * @@ -390,7 +481,7 @@ export function promiseCreate( * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export function promiseThen( +export function promiseThenRaw( promiseIndex: PromiseIndex, accountId: string, methodName: string, @@ -408,6 +499,34 @@ export function promiseThen( ) as unknown as PromiseIndex; } +/** + * Attach a callback NEAR promise to be executed after a provided promise. + * + * @param promiseIndex - The promise after which to call the callback. + * @param accountId - The account ID of the contract to perform the callback on. + * @param methodName - The name of the method to call. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export function promiseThen( + promiseIndex: PromiseIndex, + accountId: string, + methodName: string, + args: string, + amount: NearAmount, + gas: NearAmount +): PromiseIndex { + return promiseThenRaw( + promiseIndex, + accountId, + methodName, + encode(args), + amount, + gas + ); +} + /** * Join an arbitrary array of NEAR promises. * @@ -480,7 +599,7 @@ export function promiseBatchActionDeployContract( * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ -export function promiseBatchActionFunctionCall( +export function promiseBatchActionFunctionCallRaw( promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, @@ -496,6 +615,31 @@ export function promiseBatchActionFunctionCall( ); } +/** + * Attach a function call promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ +export function promiseBatchActionFunctionCall( + promiseIndex: PromiseIndex, + methodName: string, + args: string, + amount: NearAmount, + gas: NearAmount +): void { + promiseBatchActionFunctionCallRaw( + promiseIndex, + methodName, + encode(args), + amount, + gas + ); +} + /** * Attach a transfer promise action to the NEAR promise index with the provided promise index. * @@ -617,7 +761,7 @@ export function promiseBatchActionDeleteAccount( * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ -export function promiseBatchActionFunctionCallWeight( +export function promiseBatchActionFunctionCallWeightRaw( promiseIndex: PromiseIndex, methodName: string, args: Uint8Array, @@ -635,6 +779,34 @@ export function promiseBatchActionFunctionCallWeight( ); } +/** + * Attach a function call with weight promise action to the NEAR promise index with the provided promise index. + * + * @param promiseIndex - The index of the promise to attach a function call with weight action to. + * @param methodName - The name of the method to be called. + * @param args - The utf-8 string arguments to call the method with. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ +export function promiseBatchActionFunctionCallWeight( + promiseIndex: PromiseIndex, + methodName: string, + args: string, + amount: NearAmount, + gas: NearAmount, + weight: GasWeight +): void { + env.promise_batch_action_function_call_weight( + promiseIndex as unknown as bigint, + methodName, + encode(args), + amount, + gas, + weight + ); +} + /** * The number of promise results available. */ @@ -647,7 +819,7 @@ export function promiseResultsCount(): bigint { * * @param promiseIndex - The index of the promise to return the result for. */ -export function promiseResult(promiseIndex: PromiseIndex): Uint8Array { +export function promiseResultRaw(promiseIndex: PromiseIndex): Uint8Array { const status = env.promise_result(promiseIndex as unknown as bigint, 0); assert( @@ -664,6 +836,15 @@ export function promiseResult(promiseIndex: PromiseIndex): Uint8Array { return env.read_register(0); } +/** + * Returns the result of the NEAR promise for the passed promise index as utf-8 string + * + * @param promiseIndex - The index of the promise to return the result for. + */ +export function promiseResult(promiseIndex: PromiseIndex): string { + return decode(promiseResultRaw(promiseIndex)); +} + /** * Executes the promise in the NEAR WASM virtual machine. * diff --git a/packages/near-sdk-js/src/collections/lookup-map.ts b/packages/near-sdk-js/src/collections/lookup-map.ts index 7201c198a..8002449ec 100644 --- a/packages/near-sdk-js/src/collections/lookup-map.ts +++ b/packages/near-sdk-js/src/collections/lookup-map.ts @@ -22,7 +22,7 @@ export class LookupMap { */ containsKey(key: string): boolean { const storageKey = this.keyPrefix + key; - return near.storageHasKey(encode(storageKey)); + return near.storageHasKey(storageKey); } /** @@ -36,7 +36,7 @@ export class LookupMap { options?: Omit, "serializer"> ): DataType | null { const storageKey = this.keyPrefix + key; - const value = near.storageRead(encode(storageKey)); + const value = near.storageReadRaw(encode(storageKey)); return getValueWithOptions(value, options); } @@ -53,11 +53,11 @@ export class LookupMap { ): DataType | null { const storageKey = this.keyPrefix + key; - if (!near.storageRemove(encode(storageKey))) { + if (!near.storageRemove(storageKey)) { return options?.defaultValue ?? null; } - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } @@ -77,11 +77,11 @@ export class LookupMap { const storageKey = this.keyPrefix + key; const storageValue = serializeValueWithOptions(newValue, options); - if (!near.storageWrite(encode(storageKey), storageValue)) { + if (!near.storageWriteRaw(encode(storageKey), storageValue)) { return options?.defaultValue ?? null; } - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } diff --git a/packages/near-sdk-js/src/collections/lookup-set.ts b/packages/near-sdk-js/src/collections/lookup-set.ts index b2fbc289b..9d6ca4ec2 100644 --- a/packages/near-sdk-js/src/collections/lookup-set.ts +++ b/packages/near-sdk-js/src/collections/lookup-set.ts @@ -1,6 +1,6 @@ import * as near from "../api"; import { GetOptions } from "../types/collections"; -import { serializeValueWithOptions, encode } from "../utils"; +import { serializeValueWithOptions } from "../utils"; /** * A lookup set collection that stores entries in NEAR storage. @@ -22,7 +22,7 @@ export class LookupSet { options?: Pick, "serializer"> ): boolean { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return near.storageHasKey(encode(storageKey)); + return near.storageHasKey(storageKey); } /** @@ -36,7 +36,7 @@ export class LookupSet { options?: Pick, "serializer"> ): boolean { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return near.storageRemove(encode(storageKey)); + return near.storageRemove(storageKey); } /** @@ -51,7 +51,7 @@ export class LookupSet { options?: Pick, "serializer"> ): boolean { const storageKey = this.keyPrefix + serializeValueWithOptions(key, options); - return !near.storageWrite(encode(storageKey), new Uint8Array()); + return !near.storageWrite(storageKey, ""); } /** diff --git a/packages/near-sdk-js/src/collections/unordered-set.ts b/packages/near-sdk-js/src/collections/unordered-set.ts index b3d7fa6ba..0c2945c61 100644 --- a/packages/near-sdk-js/src/collections/unordered-set.ts +++ b/packages/near-sdk-js/src/collections/unordered-set.ts @@ -63,7 +63,7 @@ export class UnorderedSet { ): boolean { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - return near.storageHasKey(encode(indexLookup)); + return near.storageHasKey(indexLookup); } /** @@ -80,13 +80,13 @@ export class UnorderedSet { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - if (near.storageRead(encode(indexLookup))) { + if (near.storageRead(indexLookup)) { return false; } const nextIndex = this.length; const nextIndexRaw = serializeIndex(nextIndex); - near.storageWrite(encode(indexLookup), nextIndexRaw); + near.storageWriteRaw(encode(indexLookup), nextIndexRaw); this.elements.push(element, options); return true; @@ -101,7 +101,7 @@ export class UnorderedSet { remove(element: DataType, options?: GetOptions): boolean { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - const indexRaw = near.storageRead(encode(indexLookup)); + const indexRaw = near.storageReadRaw(encode(indexLookup)); if (!indexRaw) { return false; @@ -110,7 +110,7 @@ export class UnorderedSet { // If there is only one element then swap remove simply removes it without // swapping with the last element. if (this.length === 1) { - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); const index = deserializeIndex(indexRaw); this.elements.swapRemove(index); @@ -124,7 +124,7 @@ export class UnorderedSet { assert(!!lastElement, ERR_INCONSISTENT_STATE); - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); // If the removed element was the last element from keys, then we don't need to // reinsert the lookup back. @@ -132,7 +132,7 @@ export class UnorderedSet { const lastLookupElement = this.elementIndexPrefix + serializeValueWithOptions(lastElement, options); - near.storageWrite(encode(lastLookupElement), indexRaw); + near.storageWriteRaw(encode(lastLookupElement), indexRaw); } const index = deserializeIndex(indexRaw); @@ -148,7 +148,7 @@ export class UnorderedSet { for (const element of this.elements) { const indexLookup = this.elementIndexPrefix + serializeValueWithOptions(element, options); - near.storageRemove(encode(indexLookup)); + near.storageRemove(indexLookup); } this.elements.clear(); diff --git a/packages/near-sdk-js/src/collections/vector.ts b/packages/near-sdk-js/src/collections/vector.ts index 9e869dc51..698613a31 100644 --- a/packages/near-sdk-js/src/collections/vector.ts +++ b/packages/near-sdk-js/src/collections/vector.ts @@ -51,7 +51,7 @@ export class Vector { } const storageKey = indexToKey(this.prefix, index); - const value = near.storageRead(bytes(storageKey)); + const value = near.storageReadRaw(bytes(storageKey)); return getValueWithOptions(value, options); } @@ -75,11 +75,14 @@ export class Vector { const last = this.pop(options); assert( - near.storageWrite(bytes(key), serializeValueWithOptions(last, options)), + near.storageWriteRaw( + bytes(key), + serializeValueWithOptions(last, options) + ), ERR_INCONSISTENT_STATE ); - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } @@ -97,7 +100,10 @@ export class Vector { const key = indexToKey(this.prefix, this.length); this.length += 1; - near.storageWrite(bytes(key), serializeValueWithOptions(element, options)); + near.storageWriteRaw( + bytes(key), + serializeValueWithOptions(element, options) + ); } /** @@ -114,9 +120,9 @@ export class Vector { const lastKey = indexToKey(this.prefix, lastIndex); this.length -= 1; - assert(near.storageRemove(bytes(lastKey)), ERR_INCONSISTENT_STATE); + assert(near.storageRemoveRaw(bytes(lastKey)), ERR_INCONSISTENT_STATE); - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } @@ -137,14 +143,14 @@ export class Vector { const key = indexToKey(this.prefix, index); assert( - near.storageWrite( + near.storageWriteRaw( bytes(key), serializeValueWithOptions(element, options) ), ERR_INCONSISTENT_STATE ); - const value = near.storageGetEvicted(); + const value = near.storageGetEvictedRaw(); return getValueWithOptions(value, options); } @@ -200,7 +206,7 @@ export class Vector { clear(): void { for (let index = 0; index < this.length; index++) { const key = indexToKey(this.prefix, index); - near.storageRemove(bytes(key)); + near.storageRemoveRaw(bytes(key)); } this.length = 0; diff --git a/packages/near-sdk-js/src/near-bindgen.ts b/packages/near-sdk-js/src/near-bindgen.ts index 22ba789c9..27ea841fd 100644 --- a/packages/near-sdk-js/src/near-bindgen.ts +++ b/packages/near-sdk-js/src/near-bindgen.ts @@ -1,5 +1,5 @@ import * as near from "./api"; -import { deserialize, serialize, bytes, encode, decode } from "./utils"; +import { deserialize, serialize, bytes, encode } from "./utils"; type EmptyParameterObject = Record; type AnyObject = Record; @@ -166,16 +166,16 @@ export function NearBindgen({ } static _getState(): unknown | null { - const rawState = near.storageRead(bytes("STATE")); + const rawState = near.storageReadRaw(bytes("STATE")); return rawState ? this._deserialize(rawState) : null; } static _saveToStorage(objectToSave: unknown): void { - near.storageWrite(bytes("STATE"), this._serialize(objectToSave)); + near.storageWriteRaw(bytes("STATE"), this._serialize(objectToSave)); } static _getArgs(): unknown { - return JSON.parse(decode(near.input()) || "{}"); + return JSON.parse(near.input() || "{}"); } static _serialize(value: unknown, forReturn = false): Uint8Array { diff --git a/packages/near-sdk-js/src/promise.ts b/packages/near-sdk-js/src/promise.ts index 6bfaa4ba8..3db1f260c 100644 --- a/packages/near-sdk-js/src/promise.ts +++ b/packages/near-sdk-js/src/promise.ts @@ -50,6 +50,38 @@ export class DeployContract extends PromiseAction { * @extends {PromiseAction} */ export class FunctionCall extends PromiseAction { + /** + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + */ + constructor( + public functionName: string, + public args: string, + public amount: Balance, + public gas: Gas + ) { + super(); + } + + add(promiseIndex: PromiseIndex) { + near.promiseBatchActionFunctionCall( + promiseIndex, + this.functionName, + this.args, + this.amount, + this.gas + ); + } +} + +/** + * A function call raw promise action. + * + * @extends {PromiseAction} + */ +export class FunctionCallRaw extends PromiseAction { /** * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. @@ -66,7 +98,7 @@ export class FunctionCall extends PromiseAction { } add(promiseIndex: PromiseIndex) { - near.promiseBatchActionFunctionCall( + near.promiseBatchActionFunctionCallRaw( promiseIndex, this.functionName, this.args, @@ -82,6 +114,41 @@ export class FunctionCall extends PromiseAction { * @extends {PromiseAction} */ export class FunctionCallWeight extends PromiseAction { + /** + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + constructor( + public functionName: string, + public args: string, + public amount: Balance, + public gas: Gas, + public weight: GasWeight + ) { + super(); + } + + add(promiseIndex: PromiseIndex) { + near.promiseBatchActionFunctionCallWeight( + promiseIndex, + this.functionName, + this.args, + this.amount, + this.gas, + this.weight + ); + } +} + +/** + * A function call weight raw promise action. + * + * @extends {PromiseAction} + */ +export class FunctionCallWeightRaw extends PromiseAction { /** * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. @@ -100,7 +167,7 @@ export class FunctionCallWeight extends PromiseAction { } add(promiseIndex: PromiseIndex) { - near.promiseBatchActionFunctionCallWeight( + near.promiseBatchActionFunctionCallWeightRaw( promiseIndex, this.functionName, this.args, @@ -344,13 +411,13 @@ export class NearPromise { * Creates a function call promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. - * @param args - The arguments to be passed to the function. + * @param args - The utf-8 string arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. */ functionCall( functionName: string, - args: Uint8Array, + args: string, amount: Balance, gas: Gas ): NearPromise { @@ -358,17 +425,34 @@ export class NearPromise { } /** - * Creates a function call weight promise action and adds it to the current promise. + * Creates a function call raw promise action and adds it to the current promise. * * @param functionName - The name of the function to be called. * @param args - The arguments to be passed to the function. * @param amount - The amount of NEAR to attach to the call. * @param gas - The amount of Gas to attach to the call. + */ + functionCallRaw( + functionName: string, + args: Uint8Array, + amount: Balance, + gas: Gas + ): NearPromise { + return this.addAction(new FunctionCallRaw(functionName, args, amount, gas)); + } + + /** + * Creates a function call weight promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. + * @param args - The utf-8 string arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. * @param weight - The weight of unused Gas to use. */ functionCallWeight( functionName: string, - args: Uint8Array, + args: string, amount: Balance, gas: Gas, weight: GasWeight @@ -378,6 +462,27 @@ export class NearPromise { ); } + /** + * Creates a function call weight raw promise action and adds it to the current promise. + * + * @param functionName - The name of the function to be called. + * @param args - The arguments to be passed to the function. + * @param amount - The amount of NEAR to attach to the call. + * @param gas - The amount of Gas to attach to the call. + * @param weight - The weight of unused Gas to use. + */ + functionCallWeightRaw( + functionName: string, + args: Uint8Array, + amount: Balance, + gas: Gas, + weight: GasWeight + ): NearPromise { + return this.addAction( + new FunctionCallWeightRaw(functionName, args, amount, gas, weight) + ); + } + /** * Creates a transfer promise action and adds it to the current promise. * diff --git a/tests/src/bytes.js b/tests/src/bytes.js index f7d340df3..a8829bf72 100644 --- a/tests/src/bytes.js +++ b/tests/src/bytes.js @@ -34,29 +34,29 @@ export function log_invalid_utf16_sequence_test() { } export function storage_write_bytes() { - near.storageWrite(bytes("abc"), bytes("def")); - near.storageWrite(bytes("\x00\x01\xff"), bytes("\xe6\xb0\xb4")); - near.storageWrite(bytes("\xe6\xb0\xb4"), bytes("\x00ab")); + near.storageWriteRaw(bytes("abc"), bytes("def")); + near.storageWriteRaw(bytes("\x00\x01\xff"), bytes("\xe6\xb0\xb4")); + near.storageWriteRaw(bytes("\xe6\xb0\xb4"), bytes("\x00ab")); } export function storage_write_utf8() { - near.storageWrite(encode("水"), encode("😂")); + near.storageWrite("水", "😂"); } export function storage_read_utf8() { - near.valueReturn(near.storageRead(encode("水"))); + near.valueReturn(near.storageRead("水")); } export function storage_read_ascii_bytes() { - near.valueReturn(near.storageRead(bytes("abc"))); + near.valueReturn(near.storageRead("abc")); } export function storage_read_arbitrary_bytes_key_utf8_sequence_bytes_value() { - near.valueReturn(near.storageRead(bytes("\x00\x01\xff"))); + near.valueReturnRaw(near.storageReadRaw(bytes("\x00\x01\xff"))); } export function storage_read_utf8_sequence_bytes_key_arbitrary_bytes_value() { - near.valueReturn(near.storageRead(bytes("\xe6\xb0\xb4"))); + near.valueReturnRaw(near.storageReadRaw(bytes("\xe6\xb0\xb4"))); } export function panic_test() { diff --git a/tests/src/context_api.js b/tests/src/context_api.js index 3f72dfd6c..913d8f5b5 100644 --- a/tests/src/context_api.js +++ b/tests/src/context_api.js @@ -1,63 +1,63 @@ import { near, bytes } from "near-sdk-js"; export function get_current_account_id() { - near.valueReturn(bytes(near.currentAccountId())); + near.valueReturn(near.currentAccountId()); } export function get_signer_account_id() { - near.valueReturn(bytes(near.signerAccountId())); + near.valueReturn(near.signerAccountId()); } export function get_predecessor_account_id() { - near.valueReturn(bytes(near.predecessorAccountId())); + near.valueReturn(near.predecessorAccountId()); } export function get_signer_account_pk() { - near.valueReturn(near.signerAccountPk()); + near.valueReturnRaw(near.signerAccountPk()); } export function get_input() { - near.valueReturn(near.input()); + near.valueReturnRaw(near.inputRaw()); } export function get_storage_usage() { - near.valueReturn(bytes(near.storageUsage().toString())); + near.valueReturn(near.storageUsage().toString()); } export function get_block_height() { - near.valueReturn(bytes(near.blockHeight().toString())); + near.valueReturn(near.blockHeight().toString()); } export function get_block_timestamp() { - near.valueReturn(bytes(near.blockTimestamp().toString())); + near.valueReturn(near.blockTimestamp().toString()); } export function get_epoch_height() { - near.valueReturn(bytes(near.epochHeight().toString())); + near.valueReturn(near.epochHeight().toString()); } export function get_attached_deposit() { - near.valueReturn(bytes(JSON.stringify(near.attachedDeposit().toString()))); + near.valueReturn(JSON.stringify(near.attachedDeposit().toString())); } export function get_prepaid_gas() { - near.valueReturn(bytes(near.prepaidGas().toString())); + near.valueReturn(near.prepaidGas().toString()); } export function get_used_gas() { - near.valueReturn(bytes(near.usedGas().toString())); + near.valueReturn(near.usedGas().toString()); } export function get_random_seed() { - near.valueReturn(near.randomSeed()); + near.valueReturnRaw(near.randomSeed()); } export function get_validator_stake() { near.valueReturn( - bytes(near.validatorStake(near.signerAccountId()).toString()) + near.validatorStake(near.signerAccountId()).toString() ); } export function get_total_stake() { - near.valueReturn(bytes(near.validatorTotalStake().toString())); + near.valueReturn(near.validatorTotalStake().toString()); } diff --git a/tests/src/highlevel-promise.js b/tests/src/highlevel-promise.js index ce3350811..0c5b57a8f 100644 --- a/tests/src/highlevel-promise.js +++ b/tests/src/highlevel-promise.js @@ -1,4 +1,4 @@ -import { NearBindgen, call, NearPromise, near, bytes, str } from "near-sdk-js"; +import { NearBindgen, call, NearPromise, near, bytes } from "near-sdk-js"; import { PublicKey } from "near-sdk-js"; function callingData() { @@ -6,7 +6,7 @@ function callingData() { currentAccountId: near.currentAccountId(), signerAccountId: near.signerAccountId(), predecessorAccountId: near.predecessorAccountId(), - input: str(near.input()), + input: near.input(), }; } @@ -120,7 +120,7 @@ export class HighlevelPromiseContract { return { ...callingData(), promiseResults: arrayN(near.promiseResultsCount()).map((i) => - str(near.promiseResult(i)) + near.promiseResult(i) ), callbackArg1, }; @@ -129,9 +129,9 @@ export class HighlevelPromiseContract { @call({}) cross_contract_callback_write_state() { // Attempt to write something in state. If this one is successfully executed and not revoked, these should be in state - near.storageWrite(bytes("aaa"), bytes("bbb")); - near.storageWrite(bytes("ccc"), bytes("ddd")); - near.storageWrite(bytes("eee"), bytes("fff")); + near.storageWrite("aaa", "bbb"); + near.storageWrite("ccc", "ddd"); + near.storageWrite("eee", "fff"); } @call({}) @@ -213,7 +213,7 @@ export class HighlevelPromiseContract { 2 * Math.pow(10, 13) ) ); - near.storageWrite(bytes("aaa"), bytes("bbb")); + near.storageWrite("aaa", "bbb"); return promise; } diff --git a/tests/src/promise_api.js b/tests/src/promise_api.js index 01632c4fb..cb3b6a351 100644 --- a/tests/src/promise_api.js +++ b/tests/src/promise_api.js @@ -1,4 +1,4 @@ -import { near, str, bytes } from "near-sdk-js"; +import { near, bytes } from "near-sdk-js"; function arrayN(n) { return [...Array(Number(n)).keys()]; @@ -10,9 +10,9 @@ export function just_panic() { export function write_some_state() { // Attempt to write something in state. If this one is successfully executed and not revoked, these should be in state - near.storageWrite(bytes("aaa"), bytes("bbb")); - near.storageWrite(bytes("ccc"), bytes("ddd")); - near.storageWrite(bytes("eee"), bytes("fff")); + near.storageWrite("aaa", "bbb"); + near.storageWrite("ccc", "ddd"); + near.storageWrite("eee", "fff"); } function callingData() { @@ -20,7 +20,7 @@ function callingData() { currentAccountId: near.currentAccountId(), signerAccountId: near.signerAccountId(), predecessorAccountId: near.predecessorAccountId(), - input: str(near.input()), + input: near.input(), }; } @@ -38,7 +38,7 @@ export function cross_contract_callback() { JSON.stringify({ ...callingData(), promiseResults: arrayN(near.promiseResultsCount()).map((i) => - str(near.promiseResult(i)) + near.promiseResult(i) ), }) ) diff --git a/tests/src/storage_api.js b/tests/src/storage_api.js index 78fc86453..c7c7e56fe 100644 --- a/tests/src/storage_api.js +++ b/tests/src/storage_api.js @@ -1,33 +1,33 @@ import { near, bytes } from "near-sdk-js"; export function test_storage_write() { - near.valueReturn( + near.valueReturnRaw( bytes( near - .storageWrite(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")) + .storageWriteRaw(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")) .toString() ) ); } export function test_storage_read() { - near.valueReturn(near.storageRead(bytes("\x00tesdsst\xff"))); + near.valueReturnRaw(near.storageReadRaw(bytes("\x00tesdsst\xff"))); } export function test_storage_remove() { - near.valueReturn( - bytes(near.storageRemove(bytes("\x00tesdsst\xff")).toString()) + near.valueReturnRaw( + bytes(near.storageRemoveRaw(bytes("\x00tesdsst\xff")).toString()) ); } export function test_storage_has_key() { - near.valueReturn( - bytes(near.storageHasKey(bytes("\x00tesdsst\xff")).toString()) + near.valueReturnRaw( + bytes(near.storageHasKeyRaw(bytes("\x00tesdsst\xff")).toString()) ); } export function test_storage_get_evicted() { - near.storageWrite(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")); - near.storageWrite(bytes("\x00tesdsst\xff"), bytes("\x03\x01\xee")); - near.valueReturn(near.storageGetEvicted()); + near.storageWriteRaw(bytes("\x00tesdsst\xff"), bytes("\x00\x01\xff")); + near.storageWriteRaw(bytes("\x00tesdsst\xff"), bytes("\x03\x01\xee")); + near.valueReturnRaw(near.storageGetEvictedRaw()); } From ea494c61bde90979f813b149037e2d8867894eb5 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 13 Dec 2022 17:17:07 +0800 Subject: [PATCH 24/24] fix tests --- examples/src/cross-contract-call.js | 4 +- packages/near-sdk-js/lib/api.js | 2 +- .../cli/build-tools/near-bindgen-exporter.js | 4 +- packages/near-sdk-js/src/api.ts | 4 +- .../cli/build-tools/near-bindgen-exporter.ts | 4 +- tests/src/highlevel-promise.js | 40 +++++++++---------- tests/src/math_api.js | 10 ++--- tests/src/promise_api.js | 22 +++++----- tests/src/promise_batch_api.js | 6 +-- 9 files changed, 47 insertions(+), 49 deletions(-) diff --git a/examples/src/cross-contract-call.js b/examples/src/cross-contract-call.js index 2272e81fd..ca49f5078 100644 --- a/examples/src/cross-contract-call.js +++ b/examples/src/cross-contract-call.js @@ -20,7 +20,7 @@ export class OnCall { near.promiseBatchActionFunctionCall( promise, "get_status", - bytes(JSON.stringify({ account_id: accountId })), + JSON.stringify({ account_id: accountId }), 0, 30000000000000 ); @@ -28,7 +28,7 @@ export class OnCall { promise, near.currentAccountId(), "_set_person_on_call_private", - bytes(JSON.stringify({ accountId: accountId })), + JSON.stringify({ accountId: accountId }), 0, 30000000000000 ); diff --git a/packages/near-sdk-js/lib/api.js b/packages/near-sdk-js/lib/api.js index 169f4732a..db5127114 100644 --- a/packages/near-sdk-js/lib/api.js +++ b/packages/near-sdk-js/lib/api.js @@ -439,7 +439,7 @@ export function promiseBatchActionFunctionCallWeightRaw(promiseIndex, methodName * @param weight - The weight of unused Gas to use. */ export function promiseBatchActionFunctionCallWeight(promiseIndex, methodName, args, amount, gas, weight) { - env.promise_batch_action_function_call_weight(promiseIndex, methodName, encode(args), amount, gas, weight); + promiseBatchActionFunctionCallWeightRaw(promiseIndex, methodName, encode(args), amount, gas, weight); } /** * The number of promise results available. diff --git a/packages/near-sdk-js/lib/cli/build-tools/near-bindgen-exporter.js b/packages/near-sdk-js/lib/cli/build-tools/near-bindgen-exporter.js index 18b0910ea..3e30d919e 100644 --- a/packages/near-sdk-js/lib/cli/build-tools/near-bindgen-exporter.js +++ b/packages/near-sdk-js/lib/cli/build-tools/near-bindgen-exporter.js @@ -160,7 +160,7 @@ function saveToStorage(classId, methodType) { * if (_result && _result.constructor && _result.constructor.name === 'NearPromise') { * _result.onReturn(); * } else { - * near.valueReturn(_contract._serialize(result)); + * near.valueReturnRaw(_contract._serialize(result)); * } * } * ``` @@ -210,7 +210,7 @@ function createDeclaration(classId, methodName, methodType) { // if (_result && _result.constructor && _result.constructor.name === 'NearPromise') // _result.onReturn(); // else - // near.valueReturn(_contract._serialize(result)); + // near.valueReturnRaw(_contract._serialize(result)); executePromise(classId), ]))); } diff --git a/packages/near-sdk-js/src/api.ts b/packages/near-sdk-js/src/api.ts index 29479f940..a02108315 100644 --- a/packages/near-sdk-js/src/api.ts +++ b/packages/near-sdk-js/src/api.ts @@ -797,8 +797,8 @@ export function promiseBatchActionFunctionCallWeight( gas: NearAmount, weight: GasWeight ): void { - env.promise_batch_action_function_call_weight( - promiseIndex as unknown as bigint, + promiseBatchActionFunctionCallWeightRaw( + promiseIndex, methodName, encode(args), amount, diff --git a/packages/near-sdk-js/src/cli/build-tools/near-bindgen-exporter.ts b/packages/near-sdk-js/src/cli/build-tools/near-bindgen-exporter.ts index 94a0a0b19..8e8e733e7 100644 --- a/packages/near-sdk-js/src/cli/build-tools/near-bindgen-exporter.ts +++ b/packages/near-sdk-js/src/cli/build-tools/near-bindgen-exporter.ts @@ -238,7 +238,7 @@ function saveToStorage( * if (_result && _result.constructor && _result.constructor.name === 'NearPromise') { * _result.onReturn(); * } else { - * near.valueReturn(_contract._serialize(result)); + * near.valueReturnRaw(_contract._serialize(result)); * } * } * ``` @@ -342,7 +342,7 @@ function createDeclaration( // if (_result && _result.constructor && _result.constructor.name === 'NearPromise') // _result.onReturn(); // else - // near.valueReturn(_contract._serialize(result)); + // near.valueReturnRaw(_contract._serialize(result)); executePromise(classId), ]) ) diff --git a/tests/src/highlevel-promise.js b/tests/src/highlevel-promise.js index 0c5b57a8f..60775feb7 100644 --- a/tests/src/highlevel-promise.js +++ b/tests/src/highlevel-promise.js @@ -1,4 +1,4 @@ -import { NearBindgen, call, NearPromise, near, bytes } from "near-sdk-js"; +import { NearBindgen, call, NearPromise, near } from "near-sdk-js"; import { PublicKey } from "near-sdk-js"; function callingData() { @@ -71,14 +71,14 @@ export class HighlevelPromiseContract { let promise = NearPromise.new("callee-contract.test.near") .functionCall( "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ) .then( NearPromise.new("highlevel-promise.test.near").functionCall( "cross_contract_callback", - bytes(JSON.stringify({ callbackArg1: "def" })), + JSON.stringify({ callbackArg1: "def" }), 0, 2 * Math.pow(10, 13) ) @@ -90,13 +90,13 @@ export class HighlevelPromiseContract { test_promise_and() { let promise = NearPromise.new("callee-contract.test.near").functionCall( "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ); let promise2 = NearPromise.new("callee-contract.test.near").functionCall( "cross_contract_callee", - bytes("def"), + "def", 0, 2 * Math.pow(10, 13) ); @@ -105,7 +105,7 @@ export class HighlevelPromiseContract { .then( NearPromise.new("highlevel-promise.test.near").functionCall( "cross_contract_callback", - bytes(JSON.stringify({ callbackArg1: "ghi" })), + JSON.stringify({ callbackArg1: "ghi" }), 0, 3 * Math.pow(10, 13) ) @@ -138,7 +138,7 @@ export class HighlevelPromiseContract { callee_panic() { let promise = NearPromise.new("callee-contract.test.near").functionCall( "just_panic", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ); @@ -150,7 +150,7 @@ export class HighlevelPromiseContract { near.log("log before call the callee"); let promise = NearPromise.new("callee-contract.test.near").functionCall( "just_panic", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ); @@ -161,11 +161,11 @@ export class HighlevelPromiseContract { @call({}) callee_panic_then() { let promise = NearPromise.new("callee-contract.test.near") - .functionCall("just_panic", bytes(""), 0, 2 * Math.pow(10, 13)) + .functionCall("just_panic", "", 0, 2 * Math.pow(10, 13)) .then( NearPromise.new("highlevel-promise.test.near").functionCall( "cross_contract_callback_write_state", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ) @@ -177,13 +177,13 @@ export class HighlevelPromiseContract { callee_panic_and() { let promise = NearPromise.new("callee-contract.test.near").functionCall( "just_panic", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ); let promise2 = NearPromise.new("callee-contract.test.near").functionCall( "write_some_state", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ); @@ -192,7 +192,7 @@ export class HighlevelPromiseContract { .then( NearPromise.new("highlevel-promise.test.near").functionCall( "cross_contract_callback_write_state", - bytes(""), + "", 0, 3 * Math.pow(10, 13) ) @@ -204,11 +204,11 @@ export class HighlevelPromiseContract { @call({}) callee_success_then_panic() { let promise = NearPromise.new("callee-contract.test.near") - .functionCall("write_some_state", bytes("abc"), 0, 2 * Math.pow(10, 13)) + .functionCall("write_some_state", "abc", 0, 2 * Math.pow(10, 13)) .then( NearPromise.new("callee-contract.test.near").functionCall( "just_panic", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ) @@ -234,11 +234,11 @@ export class HighlevelPromiseContract { @call({}) handle_error_in_promise_then() { let promise = NearPromise.new("callee-contract.test.near") - .functionCall("just_panic", bytes(""), 0, 2 * Math.pow(10, 13)) + .functionCall("just_panic", "", 0, 2 * Math.pow(10, 13)) .then( NearPromise.new("highlevel-promise.test.near").functionCall( "handler", - bytes(JSON.stringify({ promiseId: 0 })), + JSON.stringify({ promiseId: 0 }), 0, 2 * Math.pow(10, 13) ) @@ -251,14 +251,14 @@ export class HighlevelPromiseContract { let promise = NearPromise.new("callee-contract.test.near") .functionCall( "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ) .and( NearPromise.new("callee-contract.test.near").functionCall( "just_panic", - bytes(""), + "", 0, 2 * Math.pow(10, 13) ) @@ -266,7 +266,7 @@ export class HighlevelPromiseContract { .then( NearPromise.new("highlevel-promise.test.near").functionCall( "handler", - bytes(JSON.stringify({ promiseId: 1 })), + JSON.stringify({ promiseId: 1 }), 0, 2 * Math.pow(10, 13) ) diff --git a/tests/src/math_api.js b/tests/src/math_api.js index 0f789130d..b7827ab4a 100644 --- a/tests/src/math_api.js +++ b/tests/src/math_api.js @@ -1,19 +1,19 @@ import { near, bytes } from "near-sdk-js"; export function test_sha256() { - near.valueReturn(near.sha256(bytes("tesdsst"))); + near.valueReturnRaw(near.sha256(bytes("tesdsst"))); } export function test_keccak256() { - near.valueReturn(near.keccak256(bytes("tesdsst"))); + near.valueReturnRaw(near.keccak256(bytes("tesdsst"))); } export function test_keccak512() { - near.valueReturn(near.keccak512(bytes("tesdsst"))); + near.valueReturnRaw(near.keccak512(bytes("tesdsst"))); } export function test_ripemd160() { - near.valueReturn(near.ripemd160(bytes("tesdsst"))); + near.valueReturnRaw(near.ripemd160(bytes("tesdsst"))); } export function test_ecrecover() { @@ -30,5 +30,5 @@ export function test_ecrecover() { let v = 1; let malleabilityFlag = 1; let ret = near.ecrecover(hash, sign, v, malleabilityFlag); - near.valueReturn(ret); + near.valueReturnRaw(ret); } diff --git a/tests/src/promise_api.js b/tests/src/promise_api.js index cb3b6a351..5916d96fa 100644 --- a/tests/src/promise_api.js +++ b/tests/src/promise_api.js @@ -1,4 +1,4 @@ -import { near, bytes } from "near-sdk-js"; +import { near } from "near-sdk-js"; function arrayN(n) { return [...Array(Number(n)).keys()]; @@ -25,23 +25,21 @@ function callingData() { } export function cross_contract_callee() { - near.valueReturn(bytes(JSON.stringify(callingData()))); + near.valueReturn(JSON.stringify(callingData())); } export function cross_contract_call_gas() { - near.valueReturn(bytes(near.prepaidGas().toString())); + near.valueReturn(near.prepaidGas().toString()); } export function cross_contract_callback() { near.valueReturn( - bytes( JSON.stringify({ ...callingData(), promiseResults: arrayN(near.promiseResultsCount()).map((i) => near.promiseResult(i) ), }) - ) ); } @@ -49,7 +47,7 @@ export function test_promise_create() { near.promiseCreate( "callee-contract.test.near", "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ); @@ -59,7 +57,7 @@ export function test_promise_create_gas_overflow() { near.promiseCreate( "callee-contract.test.near", "cross_contract_callee", - bytes("abc"), + "abc", 0, BigInt(2) ** BigInt(64) ); @@ -69,7 +67,7 @@ export function test_promise_then() { let promiseId = near.promiseCreate( "callee-contract.test.near", "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ); @@ -77,7 +75,7 @@ export function test_promise_then() { promiseId, "caller-contract.test.near", "cross_contract_callback", - bytes("def"), + "def", 0, 2 * Math.pow(10, 13) ); @@ -87,14 +85,14 @@ export function test_promise_and() { let promiseId = near.promiseCreate( "callee-contract.test.near", "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) ); let promiseId2 = near.promiseCreate( "callee-contract.test.near", "cross_contract_callee", - bytes("def"), + "def", 0, 2 * Math.pow(10, 13) ); @@ -103,7 +101,7 @@ export function test_promise_and() { promiseIdAnd, "caller-contract.test.near", "cross_contract_callback", - bytes("ghi"), + "ghi", 0, 3 * Math.pow(10, 13) ); diff --git a/tests/src/promise_batch_api.js b/tests/src/promise_batch_api.js index fe95d8eed..fe61d6fd8 100644 --- a/tests/src/promise_batch_api.js +++ b/tests/src/promise_batch_api.js @@ -1,4 +1,4 @@ -import { near, bytes, includeBytes } from "near-sdk-js"; +import { near, includeBytes } from "near-sdk-js"; export function test_promise_batch_stake() { let promiseId = near.promiseBatchCreate("caller2.test.near"); @@ -64,7 +64,7 @@ export function test_promise_batch_call_weight() { near.promiseBatchActionFunctionCallWeight( promiseId, "cross_contract_call_gas", - bytes("abc"), + "abc", 0, 0, 1 @@ -85,7 +85,7 @@ export function test_promise_batch_deploy_call() { near.promiseBatchActionFunctionCall( promiseId, "cross_contract_callee", - bytes("abc"), + "abc", 0, 2 * Math.pow(10, 13) );