diff --git a/examples/src/clean-state.js b/examples/src/clean-state.js index 4257450ee..7021a6097 100644 --- a/examples/src/clean-state.js +++ b/examples/src/clean-state.js @@ -1,7 +1,7 @@ import { NearBindgen, call, view, near } from "near-sdk-js"; @NearBindgen({}) -class CleanState { +export class CleanState { @call({}) clean({ keys }) { keys.forEach((key) => near.storageRemove(key)); diff --git a/examples/src/counter.js b/examples/src/counter.js index 92dc70da5..6b9de29f2 100644 --- a/examples/src/counter.js +++ b/examples/src/counter.js @@ -1,8 +1,8 @@ -import { NearBindgen, near, call, view, initialize } from "near-sdk-js"; +import { NearBindgen, near, call, view } from "near-sdk-js"; import { isUndefined } from "lodash-es"; @NearBindgen({}) -class Counter { +export class Counter { constructor() { this.count = 0; } diff --git a/examples/src/counter.ts b/examples/src/counter.ts index 97830aea8..1a656ecd8 100644 --- a/examples/src/counter.ts +++ b/examples/src/counter.ts @@ -1,9 +1,9 @@ -import { NearBindgen, near, call, view, initialize } from "near-sdk-js"; +import { NearBindgen, near, call, view } from "near-sdk-js"; import { isUndefined } from "lodash-es"; import { log } from "./log"; @NearBindgen({}) -class Counter { +export class Counter { count = 0; @call({}) diff --git a/examples/src/cross-contract-call.js b/examples/src/cross-contract-call.js index 4e60aad91..2272e81fd 100644 --- a/examples/src/cross-contract-call.js +++ b/examples/src/cross-contract-call.js @@ -1,7 +1,7 @@ import { NearBindgen, call, view, initialize, near, bytes } from "near-sdk-js"; @NearBindgen({ requireInit: true }) -class OnCall { +export class OnCall { constructor() { this.personOnCall = ""; this.statusMessageContract = ""; diff --git a/examples/src/fungible-token-helper.js b/examples/src/fungible-token-helper.js index 05f420781..e0a6dbf17 100644 --- a/examples/src/fungible-token-helper.js +++ b/examples/src/fungible-token-helper.js @@ -1,7 +1,7 @@ import { NearBindgen, call, view } from "near-sdk-js"; @NearBindgen({}) -class FungibleTokenHelper { +export class FungibleTokenHelper { constructor() { this.data = ""; } diff --git a/examples/src/fungible-token-lockable.js b/examples/src/fungible-token-lockable.js index 9aa1ae399..1ecf32765 100644 --- a/examples/src/fungible-token-lockable.js +++ b/examples/src/fungible-token-lockable.js @@ -52,7 +52,7 @@ class Account { } @NearBindgen({ initRequired: true }) -class LockableFungibleToken { +export class LockableFungibleToken { constructor() { this.accounts = new LookupMap("a"); // Account ID -> Account mapping this.totalSupply = 0; // Total supply of the all tokens diff --git a/examples/src/fungible-token.js b/examples/src/fungible-token.js index 08cb587f1..0af18a3b2 100644 --- a/examples/src/fungible-token.js +++ b/examples/src/fungible-token.js @@ -9,7 +9,7 @@ import { } from "near-sdk-js"; @NearBindgen({ initRequired: true }) -class FungibleToken { +export class FungibleToken { constructor() { this.accounts = new LookupMap("a"); this.totalSupply = 0; @@ -40,7 +40,7 @@ class FungibleToken { this.totalSupply = newSupply.toString(); } - internalTransfer({ senderId, receiverId, amount, memo }) { + internalTransfer({ senderId, receiverId, amount, memo: _ }) { assert(senderId != receiverId, "Sender and receiver should be different"); let amountInt = BigInt(amount); assert(amountInt > 0n, "The amount should be a positive number"); diff --git a/examples/src/log.ts b/examples/src/log.ts index 924c1e827..ec301208d 100644 --- a/examples/src/log.ts +++ b/examples/src/log.ts @@ -1,5 +1,5 @@ import { near } from "near-sdk-js"; -export function log(msg: any) { +export function log(msg: unknown) { near.log(msg); } diff --git a/examples/src/non-fungible-token-receiver.js b/examples/src/non-fungible-token-receiver.js index 7e2a29a2a..b752e87f8 100644 --- a/examples/src/non-fungible-token-receiver.js +++ b/examples/src/non-fungible-token-receiver.js @@ -1,7 +1,7 @@ import { NearBindgen, call, near, assert, initialize } from "near-sdk-js"; @NearBindgen({ requireInit: true }) -class NftContract { +export class NftContract { constructor() { this.nonFungibleTokenAccountId = ""; } diff --git a/examples/src/non-fungible-token.js b/examples/src/non-fungible-token.js index b0c6120da..c81637d10 100644 --- a/examples/src/non-fungible-token.js +++ b/examples/src/non-fungible-token.js @@ -17,7 +17,7 @@ class Token { } @NearBindgen({ requireInit: true }) -class NftContract { +export class NftContract { constructor() { this.owner_id = ""; this.owner_by_id = new LookupMap("a"); @@ -29,7 +29,13 @@ class NftContract { this.owner_by_id = new LookupMap(owner_by_id_prefix); } - internalTransfer({ sender_id, receiver_id, token_id, approval_id, memo }) { + internalTransfer({ + sender_id, + receiver_id, + token_id, + approval_id: _ai, + memo: _m, + }) { let owner_id = this.owner_by_id.get(token_id); assert(owner_id !== null, "Token not found"); @@ -125,7 +131,7 @@ class NftContract { } @call({}) - nftMint({ token_id, token_owner_id, token_metadata }) { + nftMint({ token_id, token_owner_id, token_metadata: _ }) { let sender_id = near.predecessorAccountId(); assert(sender_id === this.owner_id, "Unauthorized"); assert(this.owner_by_id.get(token_id) === null, "Token ID must be unique"); diff --git a/examples/src/parking-lot.ts b/examples/src/parking-lot.ts index c74010fb7..aa632b274 100644 --- a/examples/src/parking-lot.ts +++ b/examples/src/parking-lot.ts @@ -31,8 +31,9 @@ class Engine { } @NearBindgen({}) -class ParkingLot { +export class ParkingLot { cars: LookupMap; + constructor() { this.cars = new LookupMap("a"); } diff --git a/examples/src/status-message-collections.js b/examples/src/status-message-collections.js index 9c196223a..4a28cf6e8 100644 --- a/examples/src/status-message-collections.js +++ b/examples/src/status-message-collections.js @@ -8,7 +8,7 @@ import { } from "near-sdk-js"; @NearBindgen({}) -class StatusMessage { +export class StatusMessage { constructor() { this.records = new UnorderedMap("a"); this.uniqueValues = new LookupSet("b"); diff --git a/examples/src/status-message.js b/examples/src/status-message.js index a9c99d9e9..db77c0f03 100644 --- a/examples/src/status-message.js +++ b/examples/src/status-message.js @@ -1,7 +1,7 @@ import { NearBindgen, call, view, near } from "near-sdk-js"; @NearBindgen({}) -class StatusMessage { +export class StatusMessage { constructor() { this.records = {}; } diff --git a/examples/tsconfig.json b/examples/tsconfig.json index c68670ab7..7bebe8855 100644 --- a/examples/tsconfig.json +++ b/examples/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "experimentalDecorators": true, "target": "es2020", + "moduleResolution": "node", "noEmit": true }, "exclude": ["node_modules"] diff --git a/jsconfig.json b/jsconfig.json index f85e2a8db..43c5eea40 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,4 +1,4 @@ { "exclude": ["node_modules"], - "include": ["cli/*.js"] + "include": ["cli"] } diff --git a/tests/__tests__/test_promise_api.ava.js b/tests/__tests__/test_promise_api.ava.js index f67d28836..1cfb4202b 100644 --- a/tests/__tests__/test_promise_api.ava.js +++ b/tests/__tests__/test_promise_api.ava.js @@ -287,7 +287,7 @@ test("promise delete account", async (t) => { }); test("promise batch function call weight", async (t) => { - const { ali, caller2Contract, calleeContract } = t.context.accounts; + const { ali, caller2Contract } = t.context.accounts; let r = await ali.callRaw( caller2Contract, "test_promise_batch_call_weight", diff --git a/tests/src/bigint-serialization.ts b/tests/src/bigint-serialization.ts index 3f9b4794f..013738d08 100644 --- a/tests/src/bigint-serialization.ts +++ b/tests/src/bigint-serialization.ts @@ -1,7 +1,7 @@ -import { near, NearBindgen, call, view, initialize } from "near-sdk-js"; +import { near, NearBindgen, call, view } from "near-sdk-js"; @NearBindgen({}) -class BigIntSerializationTest { +export class BigIntSerializationTest { bigintField: bigint; constructor() { diff --git a/tests/src/decorators/payable.ts b/tests/src/decorators/payable.ts index d87c18923..5400aaf4a 100644 --- a/tests/src/decorators/payable.ts +++ b/tests/src/decorators/payable.ts @@ -1,7 +1,7 @@ import { near, NearBindgen, call, view } from "near-sdk-js"; @NearBindgen({}) -class PayableTest { +export class PayableTest { value: string; constructor() { diff --git a/tests/src/decorators/private.ts b/tests/src/decorators/private.ts index a6875b15e..cad023dbe 100644 --- a/tests/src/decorators/private.ts +++ b/tests/src/decorators/private.ts @@ -1,7 +1,7 @@ import { near, NearBindgen, call, view } from "near-sdk-js"; @NearBindgen({}) -class PrivateTest { +export class PrivateTest { value: string; constructor() { diff --git a/tests/src/decorators/require_init_false.ts b/tests/src/decorators/require_init_false.ts index 181822cba..5c24c597e 100644 --- a/tests/src/decorators/require_init_false.ts +++ b/tests/src/decorators/require_init_false.ts @@ -1,7 +1,7 @@ import { near, NearBindgen, call, view, initialize } from "near-sdk-js"; @NearBindgen({ requireInit: false }) -class NBTest { +export class NBTest { status: string; constructor() { diff --git a/tests/src/decorators/require_init_true.ts b/tests/src/decorators/require_init_true.ts index 55ce0db83..6d813619b 100644 --- a/tests/src/decorators/require_init_true.ts +++ b/tests/src/decorators/require_init_true.ts @@ -1,7 +1,7 @@ import { near, NearBindgen, call, view, initialize } from "near-sdk-js"; @NearBindgen({ requireInit: true }) -class NBTest { +export class NBTest { status: string; constructor() { diff --git a/tests/src/function-params.js b/tests/src/function-params.js index 237c18c2d..18253ea1c 100644 --- a/tests/src/function-params.js +++ b/tests/src/function-params.js @@ -4,7 +4,7 @@ import { NearBindgen, call, view, near } from "near-sdk-js"; * Simple contract to test function parameters */ @NearBindgen({}) -class FunctionParamsTestContract { +export class FunctionParamsTestContract { constructor() { this.val1 = "default1"; this.val2 = "default2"; diff --git a/tests/src/highlevel-promise.js b/tests/src/highlevel-promise.js index 4b6dd1d97..0743a0c4b 100644 --- a/tests/src/highlevel-promise.js +++ b/tests/src/highlevel-promise.js @@ -1,4 +1,4 @@ -import { NearBindgen, call, view, NearPromise, near, bytes } from "near-sdk-js"; +import { NearBindgen, call, NearPromise, near, bytes } from "near-sdk-js"; import { PublicKey } from "near-sdk-js/lib/types"; function callingData() { @@ -15,7 +15,7 @@ function arrayN(n) { } @NearBindgen({}) -class HighlevelPromiseContract { +export class HighlevelPromiseContract { @call({}) test_promise_batch_stake() { let promise = NearPromise.new("highlevel-promise.test.near").stake( diff --git a/tests/src/lookup-map.js b/tests/src/lookup-map.js index af2367ce6..2f7cc382b 100644 --- a/tests/src/lookup-map.js +++ b/tests/src/lookup-map.js @@ -2,7 +2,7 @@ import { NearBindgen, call, view, LookupMap } from "near-sdk-js"; import { House, Room } from "./model.js"; @NearBindgen({}) -class LookupMapTestContract { +export class LookupMapTestContract { constructor() { this.lookupMap = new LookupMap("a"); } diff --git a/tests/src/lookup-set.js b/tests/src/lookup-set.js index 43f16ef09..f5dc9d2a9 100644 --- a/tests/src/lookup-set.js +++ b/tests/src/lookup-set.js @@ -2,7 +2,7 @@ import { NearBindgen, call, view, LookupSet } from "near-sdk-js"; import { House, Room } from "./model.js"; @NearBindgen({}) -class LookupSetTestContract { +export class LookupSetTestContract { constructor() { this.lookupSet = new LookupSet("a"); } diff --git a/tests/src/public-key.js b/tests/src/public-key.js index 46822f9ed..a62a6480a 100644 --- a/tests/src/public-key.js +++ b/tests/src/public-key.js @@ -1,4 +1,4 @@ -import { near, bytes, types } from "near-sdk-js"; +import { near, bytes } from "near-sdk-js"; import { CurveType, PublicKey } from "near-sdk-js/lib/types"; import { assert } from "near-sdk-js/lib/utils"; diff --git a/tests/src/typescript.ts b/tests/src/typescript.ts index b0347a53c..294fa1b97 100644 --- a/tests/src/typescript.ts +++ b/tests/src/typescript.ts @@ -1,7 +1,7 @@ import { NearBindgen, view } from "near-sdk-js"; @NearBindgen({}) -class TypeScriptTestContract { +export class TypeScriptTestContract { @view({}) bigint() { // JSON.stringify cannot seriaize a BigInt, need manually toString diff --git a/tests/src/unordered-map.js b/tests/src/unordered-map.js index b4528816e..8658d7955 100644 --- a/tests/src/unordered-map.js +++ b/tests/src/unordered-map.js @@ -1,8 +1,8 @@ -import { NearBindgen, call, view, UnorderedMap, near } from "near-sdk-js"; +import { NearBindgen, call, view, UnorderedMap } from "near-sdk-js"; import { House, Room } from "./model.js"; @NearBindgen({}) -class UnorderedMapTestContract { +export class UnorderedMapTestContract { constructor() { this.unorderedMap = new UnorderedMap("a"); } diff --git a/tests/src/unordered-set.js b/tests/src/unordered-set.js index 4392fff50..1637dc959 100644 --- a/tests/src/unordered-set.js +++ b/tests/src/unordered-set.js @@ -2,7 +2,7 @@ import { NearBindgen, call, view, UnorderedSet } from "near-sdk-js"; import { House, Room } from "./model.js"; @NearBindgen({}) -class UnorderedSetTestContract { +export class UnorderedSetTestContract { constructor() { this.unorderedSet = new UnorderedSet("a"); } diff --git a/tests/src/vector.js b/tests/src/vector.js index b46b94315..d1f873784 100644 --- a/tests/src/vector.js +++ b/tests/src/vector.js @@ -2,7 +2,7 @@ import { NearBindgen, call, view, Vector } from "near-sdk-js"; import { House, Room } from "./model.js"; @NearBindgen({}) -class VectorTestContract { +export class VectorTestContract { constructor() { this.vector = new Vector("a"); }