Skip to content

Commit

Permalink
Merge pull request #366 from fospring/feat/remove-condition-compile
Browse files Browse the repository at this point in the history
feat: remove condition compile for host function
  • Loading branch information
ailisp authored Sep 20, 2023
2 parents ff58043 + 7ff88db commit 8c579d5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
10 changes: 3 additions & 7 deletions packages/near-sdk-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ import { near } from "near-sdk-js";
let signer = near.signerAccountId();
```

To use nightly host functions, such as `altBn128G1Sum`, your contract need to be built with nightly enabled. Use:

```
export NEAR_NIGHTLY=1
pnpm build
```

### About Type

NEAR-SDK-JS is written in TypeScript, so every API function has a type specified by signature that looks familiar to JavaScript/TypeScript Developers. Two types in the signature need a special attention:
Expand Down Expand Up @@ -120,6 +113,9 @@ function usedGas(): bigint;
### Math API

```
function altBn128G1Multiexp(value: Uint8Array): Uint8Array;
function altBn128G1Sum(value: Uint8Array): Uint8Array;
function altBn128PairingCheck(value: Uint8Array): boolean;
function randomSeed(): Uint8Array;
function sha256(value: Uint8Array): Uint8Array;
function keccak256(value: Uint8Array): Uint8Array;
Expand Down
2 changes: 0 additions & 2 deletions packages/near-sdk-js/builder/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ 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;
Expand Down
5 changes: 1 addition & 4 deletions packages/near-sdk-js/lib/cli/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions packages/near-sdk-js/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,7 @@ async function createWasmContract(
const WASI_SDK_PATH = `${NEAR_SDK_JS}/lib/cli/deps/wasi-sdk`;

const CC = `${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot`;
let DEFS = `-D_GNU_SOURCE '-DCONFIG_VERSION="2021-03-27"' -DCONFIG_BIGNUM`;

if (process.env.NEAR_NIGHTLY) {
DEFS = DEFS + " -DNIGHTLY";
}
const DEFS = `-D_GNU_SOURCE '-DCONFIG_VERSION="2021-03-27"' -DCONFIG_BIGNUM`;

const INCLUDES = `-I${QJSC_DIR} -I.`;
const ORIGINAL_BUILDER_PATH = `${NEAR_SDK_JS}/builder/builder.c`;
Expand Down

0 comments on commit 8c579d5

Please sign in to comment.