diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6f015dee9f..4c85efab60 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,19 +15,11 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x + cache: pip - uses: actions/setup-node@v4 with: node-version: 20.x - - uses: actions/cache@v4 - with: - path: ~/.cache/pip3 - key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }} - - uses: actions/cache@v4 - with: - path: | - ~/.npm - ~/.autorest - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - run: pip3 install -r docs/requirements.txt - run: git config --global user.email "github-action@users.noreply.github.com" - run: git config --global user.name "GitHub Action" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c265206bb..7ca1af1ca8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,12 +14,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20.x - - uses: actions/cache@v4 - with: - path: | - ~/.npm - ~/.autorest - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + cache: npm - run: npm ci - name: Run Commitlint if: github.event_name == 'pull_request' diff --git a/babel.esm.config.js b/babel.esm.config.js index 29e6972224..ecbf59f9dd 100644 --- a/babel.esm.config.js +++ b/babel.esm.config.js @@ -4,15 +4,12 @@ config.presets .filter((plugin) => Array.isArray(plugin)) .find(([name]) => name === '@babel/preset-env')[1].modules = false; -config.plugins.push( - ['add-import-extension', { extension: 'js' }], - [ - 'import-globals', - { - Buffer: { moduleName: 'buffer', exportName: 'Buffer' }, - }, - ], -); +config.plugins.push([ + 'import-globals', + { + Buffer: { moduleName: 'buffer', exportName: 'Buffer' }, + }, +]); config.plugins = config.plugins.filter((p) => p !== 'babel-plugin-transform-import-meta'); export default config; diff --git a/package-lock.json b/package-lock.json index fd1229408f..1400266224 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,7 @@ "tweetnacl": "^1.0.3", "tweetnacl-auth": "^1.0.1", "varuint-bitcoin": "^2.0.0", + "webextension-polyfill": "^0.12.0", "websocket": "^1.0.35", "ws": "^8.18.0" }, @@ -63,7 +64,6 @@ "@typescript-eslint/parser": "^7.15.0", "autorest": "^3.7.1", "babel-loader": "^9.2.1", - "babel-plugin-add-import-extension": "^1.6.0", "babel-plugin-import-globals": "^2.0.0", "babel-plugin-transform-import-meta": "^2.2.1", "chai": "^5.1.1", @@ -4848,19 +4848,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/babel-plugin-add-import-extension": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-plugin-add-import-extension/-/babel-plugin-add-import-extension-1.6.0.tgz", - "integrity": "sha512-JVSQPMzNzN/S4wPRoKQ7+u8PlkV//BPUMnfWVbr63zcE+6yHdU2Mblz10Vf7qe+6Rmu4svF5jG7JxdcPi9VvKg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "peerDependencies": { - "@babel/core": ">=7.0.0" - } - }, "node_modules/babel-plugin-import-globals": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/babel-plugin-import-globals/-/babel-plugin-import-globals-2.0.0.tgz", @@ -15801,6 +15788,12 @@ "node": ">=10.13.0" } }, + "node_modules/webextension-polyfill": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.12.0.tgz", + "integrity": "sha512-97TBmpoWJEE+3nFBQ4VocyCdLKfw54rFaJ6EVQYLBCXqCIpLSZkwGgASpv4oPt9gdKCJ80RJlcmNzNn008Ag6Q==", + "license": "MPL-2.0" + }, "node_modules/webpack": { "version": "5.95.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz", diff --git a/package.json b/package.json index 3e23f0ace2..f14ed92cd8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "build:es": "babel src --config-file ./babel.esm.config.js --out-dir es --extensions .ts --source-maps true", "build:api:node": "autorest tooling/autorest/node.yaml && node tooling/autorest/postprocessing.js node", "build:api:compiler": "node tooling/autorest/compiler-prepare.js && autorest tooling/autorest/compiler.yaml && node tooling/autorest/postprocessing.js compiler", - "build:api:middleware": "node tooling/autorest/middleware-prepare.js && autorest tooling/autorest/middleware.yaml && node tooling/autorest/postprocessing.js middleware", + "rem:build:api:middleware": "node tooling/autorest/middleware-prepare.js", + "build:api:middleware": "autorest tooling/autorest/middleware.yaml && node tooling/autorest/postprocessing.js middleware", "build:generate": "tsx tooling/generate-schema.ts", "build": "run-p build:api:* build:assets build:generate && run-p build:dist build:es build:types", "docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.js", @@ -87,6 +88,7 @@ "tweetnacl": "^1.0.3", "tweetnacl-auth": "^1.0.1", "varuint-bitcoin": "^2.0.0", + "webextension-polyfill": "^0.12.0", "websocket": "^1.0.35", "ws": "^8.18.0" }, @@ -116,7 +118,6 @@ "@typescript-eslint/parser": "^7.15.0", "autorest": "^3.7.1", "babel-loader": "^9.2.1", - "babel-plugin-add-import-extension": "^1.6.0", "babel-plugin-import-globals": "^2.0.0", "babel-plugin-transform-import-meta": "^2.2.1", "chai": "^5.1.1", diff --git a/src/AeSdk.ts b/src/AeSdk.ts index 98c22cd9ae..9522fb007a 100644 --- a/src/AeSdk.ts +++ b/src/AeSdk.ts @@ -1,8 +1,8 @@ -import AeSdkBase from './AeSdkBase'; -import { OnAccount } from './AeSdkMethods'; -import AccountBase from './account/Base'; -import { decode, Encoded } from './utils/encoder'; -import { UnavailableAccountError } from './utils/errors'; +import AeSdkBase from './AeSdkBase.js'; +import { OnAccount } from './AeSdkMethods.js'; +import AccountBase from './account/Base.js'; +import { decode, Encoded } from './utils/encoder.js'; +import { UnavailableAccountError } from './utils/errors.js'; export default class AeSdk extends AeSdkBase { accounts: { [key: Encoded.AccountAddress]: AccountBase } = {}; diff --git a/src/AeSdkAepp.ts b/src/AeSdkAepp.ts index 8cd604f2be..db33e14a5e 100644 --- a/src/AeSdkAepp.ts +++ b/src/AeSdkAepp.ts @@ -1,8 +1,8 @@ -import AeSdkBase from './AeSdkBase'; -import { OnAccount } from './AeSdkMethods'; -import AccountBase from './account/Base'; -import AccountRpc from './account/Rpc'; -import { decode, Encoded } from './utils/encoder'; +import AeSdkBase from './AeSdkBase.js'; +import { OnAccount } from './AeSdkMethods.js'; +import AccountBase from './account/Base.js'; +import AccountRpc from './account/Rpc.js'; +import { decode, Encoded } from './utils/encoder.js'; import { Accounts, RPC_VERSION, @@ -12,18 +12,18 @@ import { AeppApi, Node as NodeRpc, NetworkToSelect, -} from './aepp-wallet-communication/rpc/types'; -import RpcClient from './aepp-wallet-communication/rpc/RpcClient'; -import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema'; +} from './aepp-wallet-communication/rpc/types.js'; +import RpcClient from './aepp-wallet-communication/rpc/RpcClient.js'; +import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema.js'; import { AlreadyConnectedError, NoWalletConnectedError, UnsubscribedAccountError, UnAuthorizedAccountError, RpcConnectionError, -} from './utils/errors'; -import Node from './Node'; -import BrowserConnection from './aepp-wallet-communication/connection/Browser'; +} from './utils/errors.js'; +import Node from './Node.js'; +import BrowserConnection from './aepp-wallet-communication/connection/Browser.js'; /** * RPC handler for AEPP side diff --git a/src/AeSdkBase.ts b/src/AeSdkBase.ts index 67dd5ccddf..ad10750db0 100644 --- a/src/AeSdkBase.ts +++ b/src/AeSdkBase.ts @@ -1,16 +1,16 @@ -import Node from './Node'; -import AccountBase from './account/Base'; +import Node from './Node.js'; +import AccountBase from './account/Base.js'; import { CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError, -} from './utils/errors'; -import { Encoded } from './utils/encoder'; -import { wrapWithProxy } from './utils/wrap-proxy'; -import CompilerBase from './contract/compiler/Base'; -import AeSdkMethods, { OnAccount, AeSdkMethodsOptions, WrappedOptions } from './AeSdkMethods'; +} from './utils/errors.js'; +import { Encoded } from './utils/encoder.js'; +import { wrapWithProxy } from './utils/wrap-proxy.js'; +import CompilerBase from './contract/compiler/Base.js'; +import AeSdkMethods, { OnAccount, AeSdkMethodsOptions, WrappedOptions } from './AeSdkMethods.js'; type NodeInfo = Awaited> & { name: string }; diff --git a/src/AeSdkMethods.ts b/src/AeSdkMethods.ts index c29f56c72d..d1eab48d6c 100644 --- a/src/AeSdkMethods.ts +++ b/src/AeSdkMethods.ts @@ -1,15 +1,15 @@ -import * as chainMethods from './chain'; -import { sendTransaction } from './send-transaction'; -import * as spendMethods from './spend'; -import * as contractGaMethods from './contract/ga'; -import { buildTxAsync } from './tx/builder'; -import { mapObject, UnionToIntersection } from './utils/other'; -import { wrapWithProxy } from './utils/wrap-proxy'; -import Node from './Node'; -import { TxParamsAsync } from './tx/builder/schema.generated'; -import AccountBase from './account/Base'; -import { Encoded } from './utils/encoder'; -import CompilerBase from './contract/compiler/Base'; +import * as chainMethods from './chain.js'; +import { sendTransaction } from './send-transaction.js'; +import * as spendMethods from './spend.js'; +import * as contractGaMethods from './contract/ga.js'; +import { buildTxAsync } from './tx/builder/index.js'; +import { mapObject, UnionToIntersection } from './utils/other.js'; +import { wrapWithProxy } from './utils/wrap-proxy.js'; +import Node from './Node.js'; +import { TxParamsAsync } from './tx/builder/schema.generated.js'; +import AccountBase from './account/Base.js'; +import { Encoded } from './utils/encoder.js'; +import CompilerBase from './contract/compiler/Base.js'; export type OnAccount = Encoded.AccountAddress | AccountBase | undefined; diff --git a/src/AeSdkWallet.ts b/src/AeSdkWallet.ts index ab5d86eb2e..8b201dc84b 100644 --- a/src/AeSdkWallet.ts +++ b/src/AeSdkWallet.ts @@ -1,7 +1,7 @@ import nacl from 'tweetnacl'; -import AeSdk from './AeSdk'; -import verifyTransaction from './tx/validator'; -import RpcClient from './aepp-wallet-communication/rpc/RpcClient'; +import AeSdk from './AeSdk.js'; +import verifyTransaction from './tx/validator.js'; +import RpcClient from './aepp-wallet-communication/rpc/RpcClient.js'; import { METHODS, RPC_STATUS, @@ -11,10 +11,10 @@ import { RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError, -} from './aepp-wallet-communication/schema'; -import { InternalError, UnknownRpcClientError } from './utils/errors'; -import AccountBase from './account/Base'; -import BrowserConnection from './aepp-wallet-communication/connection/Browser'; +} from './aepp-wallet-communication/schema.js'; +import { InternalError, UnknownRpcClientError } from './utils/errors.js'; +import AccountBase from './account/Base.js'; +import BrowserConnection from './aepp-wallet-communication/connection/Browser.js'; import { Accounts, AeppApi, @@ -23,9 +23,9 @@ import { RPC_VERSION, WalletApi, WalletInfo, -} from './aepp-wallet-communication/rpc/types'; -import { Encoded, Encoding, encode, decode } from './utils/encoder'; -import jsonBig from './utils/json-big'; +} from './aepp-wallet-communication/rpc/types.js'; +import { Encoded, Encoding, encode, decode } from './utils/encoder.js'; +import jsonBig from './utils/json-big.js'; type RpcClientWallet = RpcClient; diff --git a/src/Middleware.ts b/src/Middleware.ts index 6ef64eed8f..6de107590b 100644 --- a/src/Middleware.ts +++ b/src/Middleware.ts @@ -7,15 +7,15 @@ import { parseBigIntPolicy, genVersionCheckPolicy, genRetryOnFailurePolicy, -} from './utils/autorest'; +} from './utils/autorest.js'; import { Middleware as MiddlewareApi, MiddlewareOptionalParams, ErrorResponse, -} from './apis/middleware'; -import { operationSpecs } from './apis/middleware/middleware'; -import { IllegalArgumentError, InternalError } from './utils/errors'; -import { MiddlewarePage, isMiddlewareRawPage } from './utils/MiddlewarePage'; +} from './apis/middleware/index.js'; +import { operationSpecs } from './apis/middleware/middleware.js'; +import { IllegalArgumentError, InternalError } from './utils/errors.js'; +import { MiddlewarePage, isMiddlewareRawPage } from './utils/MiddlewarePage.js'; export default class Middleware extends MiddlewareApi { /** diff --git a/src/MiddlewareSubscriber.ts b/src/MiddlewareSubscriber.ts index 3a0e80050b..7a3e7b9ba0 100644 --- a/src/MiddlewareSubscriber.ts +++ b/src/MiddlewareSubscriber.ts @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import WebSocket from 'isomorphic-ws'; -import { BaseError, UnexpectedTsError, InternalError } from './utils/errors'; -import { Encoded } from './utils/encoder'; +import { BaseError, UnexpectedTsError, InternalError } from './utils/errors.js'; +import { Encoded } from './utils/encoder.js'; interface Message { payload: Object; diff --git a/src/Node.ts b/src/Node.ts index 47113ef029..a140d7715e 100644 --- a/src/Node.ts +++ b/src/Node.ts @@ -8,10 +8,10 @@ import { parseBigIntPolicy, genVersionCheckPolicy, genRetryOnFailurePolicy, -} from './utils/autorest'; -import { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node'; -import { UnsupportedVersionError } from './utils/errors'; -import { ConsensusProtocolVersion } from './tx/builder/constants'; +} from './utils/autorest.js'; +import { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node/index.js'; +import { UnsupportedVersionError } from './utils/errors.js'; +import { ConsensusProtocolVersion } from './tx/builder/constants.js'; interface NodeInfo { url: string; diff --git a/src/account/Base.ts b/src/account/Base.ts index 838a81b7a3..806b1158ee 100644 --- a/src/account/Base.ts +++ b/src/account/Base.ts @@ -1,8 +1,8 @@ -import { Encoded } from '../utils/encoder'; -import Node from '../Node'; -import CompilerBase from '../contract/compiler/Base'; -import { Int } from '../tx/builder/constants'; -import { AciValue, Domain } from '../utils/typed-data'; +import { Encoded } from '../utils/encoder.js'; +import Node from '../Node.js'; +import CompilerBase from '../contract/compiler/Base.js'; +import { Int } from '../tx/builder/constants.js'; +import { AciValue, Domain } from '../utils/typed-data.js'; interface AuthData { fee?: Int; diff --git a/src/account/BaseFactory.ts b/src/account/BaseFactory.ts index 60602c81f0..dfe1bbe5fe 100644 --- a/src/account/BaseFactory.ts +++ b/src/account/BaseFactory.ts @@ -1,5 +1,5 @@ -import Node from '../Node'; -import AccountBase from './Base'; +import Node from '../Node.js'; +import AccountBase from './Base.js'; /** * A factory class that generates instances of AccountBase by index. diff --git a/src/account/Generalized.ts b/src/account/Generalized.ts index db579ee2ab..d050c9ee3e 100644 --- a/src/account/Generalized.ts +++ b/src/account/Generalized.ts @@ -1,15 +1,15 @@ -import AccountBase from './Base'; +import AccountBase from './Base.js'; import { ArgumentError, InternalError, InvalidAuthDataError, NotImplementedError, -} from '../utils/errors'; -import { decode, Encoded } from '../utils/encoder'; -import { getAccount } from '../chain'; -import Contract from '../contract/Contract'; -import { buildTxAsync, buildTx } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; +} from '../utils/errors.js'; +import { decode, Encoded } from '../utils/encoder.js'; +import { getAccount } from '../chain.js'; +import Contract from '../contract/Contract.js'; +import { buildTxAsync, buildTx } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; /** * Generalized account class diff --git a/src/account/Ledger.ts b/src/account/Ledger.ts index 9e5bcff697..4846081118 100644 --- a/src/account/Ledger.ts +++ b/src/account/Ledger.ts @@ -1,9 +1,9 @@ import type Transport from '@ledgerhq/hw-transport'; -import AccountBase from './Base'; -import { ArgumentError, NotImplementedError } from '../utils/errors'; -import { decode, Encoded } from '../utils/encoder'; -import { buildTx } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; +import AccountBase from './Base.js'; +import { ArgumentError, NotImplementedError } from '../utils/errors.js'; +import { decode, Encoded } from '../utils/encoder.js'; +import { buildTx } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; export const CLA = 0xe0; export const GET_ADDRESS = 0x02; diff --git a/src/account/LedgerFactory.ts b/src/account/LedgerFactory.ts index 3ad1744b95..fe355d6c6b 100644 --- a/src/account/LedgerFactory.ts +++ b/src/account/LedgerFactory.ts @@ -1,9 +1,9 @@ import type Transport from '@ledgerhq/hw-transport'; -import AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger'; -import { UnsupportedVersionError } from '../utils/errors'; -import { Encoded } from '../utils/encoder'; -import semverSatisfies from '../utils/semver-satisfies'; -import AccountBaseFactory from './BaseFactory'; +import AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger.js'; +import { UnsupportedVersionError } from '../utils/errors.js'; +import { Encoded } from '../utils/encoder.js'; +import semverSatisfies from '../utils/semver-satisfies.js'; +import AccountBaseFactory from './BaseFactory.js'; interface AppConfiguration { version: string; diff --git a/src/account/Memory.ts b/src/account/Memory.ts index d68169c02d..29ef93d353 100644 --- a/src/account/Memory.ts +++ b/src/account/Memory.ts @@ -1,12 +1,12 @@ import nacl from 'tweetnacl'; -import AccountBase from './Base'; -import { hash, messageToHash, messagePrefixLength } from '../utils/crypto'; -import { ArgumentError } from '../utils/errors'; -import { decode, encode, Encoded, Encoding } from '../utils/encoder'; -import { concatBuffers } from '../utils/other'; -import { hashTypedData, AciValue } from '../utils/typed-data'; -import { buildTx } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; +import AccountBase from './Base.js'; +import { hash, messageToHash, messagePrefixLength } from '../utils/crypto.js'; +import { ArgumentError } from '../utils/errors.js'; +import { decode, encode, Encoded, Encoding } from '../utils/encoder.js'; +import { concatBuffers } from '../utils/other.js'; +import { hashTypedData, AciValue } from '../utils/typed-data.js'; +import { buildTx } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; export function getBufferToSign( transaction: Encoded.Transaction, diff --git a/src/account/Metamask.ts b/src/account/Metamask.ts index 0318641c28..64926cfef4 100644 --- a/src/account/Metamask.ts +++ b/src/account/Metamask.ts @@ -1,7 +1,7 @@ import type { BaseProvider } from '@metamask/providers'; -import AccountBase from './Base'; -import { Encoded } from '../utils/encoder'; -import { ArgumentError, InternalError, NotImplementedError } from '../utils/errors'; +import AccountBase from './Base.js'; +import { Encoded } from '../utils/encoder.js'; +import { ArgumentError, InternalError, NotImplementedError } from '../utils/errors.js'; export const snapId = 'npm:@aeternity-snap/plugin'; diff --git a/src/account/MetamaskFactory.ts b/src/account/MetamaskFactory.ts index d2d72ec0b5..b39a440b51 100644 --- a/src/account/MetamaskFactory.ts +++ b/src/account/MetamaskFactory.ts @@ -1,9 +1,13 @@ import type { BaseProvider } from '@metamask/providers'; -import { InternalError, UnsupportedPlatformError, UnsupportedVersionError } from '../utils/errors'; -import { Encoded } from '../utils/encoder'; -import semverSatisfies from '../utils/semver-satisfies'; -import AccountBaseFactory from './BaseFactory'; -import AccountMetamask, { invokeSnap, snapId } from './Metamask'; +import { + InternalError, + UnsupportedPlatformError, + UnsupportedVersionError, +} from '../utils/errors.js'; +import { Encoded } from '../utils/encoder.js'; +import semverSatisfies from '../utils/semver-satisfies.js'; +import AccountBaseFactory from './BaseFactory.js'; +import AccountMetamask, { invokeSnap, snapId } from './Metamask.js'; const snapMinVersion = '0.0.9'; const snapMaxVersion = '0.1.0'; diff --git a/src/account/MnemonicFactory.ts b/src/account/MnemonicFactory.ts index e89fe1c98e..52ec653115 100644 --- a/src/account/MnemonicFactory.ts +++ b/src/account/MnemonicFactory.ts @@ -1,10 +1,10 @@ import { mnemonicToSeed } from '@scure/bip39'; import tweetnaclAuth from 'tweetnacl-auth'; -import AccountBaseFactory from './BaseFactory'; -import AccountMemory from './Memory'; -import { encode, Encoding, Encoded, decode } from '../utils/encoder'; -import { concatBuffers } from '../utils/other'; -import { InternalError } from '../utils/errors'; +import AccountBaseFactory from './BaseFactory.js'; +import AccountMemory from './Memory.js'; +import { encode, Encoding, Encoded, decode } from '../utils/encoder.js'; +import { concatBuffers } from '../utils/other.js'; +import { InternalError } from '../utils/errors.js'; export const ED25519_CURVE = Buffer.from('ed25519 seed'); const HARDENED_OFFSET = 0x80000000; diff --git a/src/account/Rpc.ts b/src/account/Rpc.ts index 82258623dd..54ca1ca672 100644 --- a/src/account/Rpc.ts +++ b/src/account/Rpc.ts @@ -1,9 +1,9 @@ -import AccountBase from './Base'; -import { METHODS } from '../aepp-wallet-communication/schema'; -import { ArgumentError, UnsupportedProtocolError } from '../utils/errors'; -import { Encoded, Encoding, decode, encode } from '../utils/encoder'; -import RpcClient from '../aepp-wallet-communication/rpc/RpcClient'; -import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types'; +import AccountBase from './Base.js'; +import { METHODS } from '../aepp-wallet-communication/schema.js'; +import { ArgumentError, UnsupportedProtocolError } from '../utils/errors.js'; +import { Encoded, Encoding, decode, encode } from '../utils/encoder.js'; +import RpcClient from '../aepp-wallet-communication/rpc/RpcClient.js'; +import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types.js'; /** * Account provided by wallet diff --git a/src/aens.ts b/src/aens.ts index 5de0d2038c..bb6fc583eb 100644 --- a/src/aens.ts +++ b/src/aens.ts @@ -6,19 +6,19 @@ * repository. */ -import BigNumber from 'bignumber.js'; -import { genSalt, isAddressValid } from './utils/crypto'; -import { commitmentHash, isAuctionName } from './tx/builder/helpers'; -import { Tag, AensName } from './tx/builder/constants'; -import { Encoded, Encoding } from './utils/encoder'; -import { LogicError } from './utils/errors'; -import { getName } from './chain'; -import { sendTransaction, SendTransactionOptions } from './send-transaction'; -import { Optional } from './utils/other'; -import { buildTxAsync, BuildTxOptions } from './tx/builder'; -import Node from './Node'; -import AccountBase from './account/Base'; -import { AddressEncodings } from './tx/builder/field-types/address'; +import { BigNumber } from 'bignumber.js'; +import { genSalt, isAddressValid } from './utils/crypto.js'; +import { commitmentHash, isAuctionName } from './tx/builder/helpers.js'; +import { Tag, AensName } from './tx/builder/constants.js'; +import { Encoded, Encoding } from './utils/encoder.js'; +import { LogicError } from './utils/errors.js'; +import { getName } from './chain.js'; +import { sendTransaction, SendTransactionOptions } from './send-transaction.js'; +import { Optional } from './utils/other.js'; +import { buildTxAsync, BuildTxOptions } from './tx/builder/index.js'; +import Node from './Node.js'; +import AccountBase from './account/Base.js'; +import { AddressEncodings } from './tx/builder/field-types/address.js'; interface NameRevokeOptions extends BuildTxOptions, diff --git a/src/aepp-wallet-communication/WalletConnectorFrame.ts b/src/aepp-wallet-communication/WalletConnectorFrame.ts index 4b737f3349..0f6134f651 100644 --- a/src/aepp-wallet-communication/WalletConnectorFrame.ts +++ b/src/aepp-wallet-communication/WalletConnectorFrame.ts @@ -1,6 +1,6 @@ -import { Network } from './rpc/types'; -import BrowserConnection from './connection/Browser'; -import WalletConnectorFrameBase from './WalletConnectorFrameBase'; +import { Network } from './rpc/types.js'; +import BrowserConnection from './connection/Browser.js'; +import WalletConnectorFrameBase from './WalletConnectorFrameBase.js'; interface EventsNetworkId { networkIdChange: (networkId: string) => void; diff --git a/src/aepp-wallet-communication/WalletConnectorFrameBase.ts b/src/aepp-wallet-communication/WalletConnectorFrameBase.ts index 45feb8e832..f54b4b9bec 100644 --- a/src/aepp-wallet-communication/WalletConnectorFrameBase.ts +++ b/src/aepp-wallet-communication/WalletConnectorFrameBase.ts @@ -1,11 +1,18 @@ -import EventEmitter from 'eventemitter3'; -import AccountRpc from '../account/Rpc'; -import { Encoded } from '../utils/encoder'; -import { Accounts, RPC_VERSION, Network, WalletApi, AeppApi, NetworkToSelect } from './rpc/types'; -import RpcClient from './rpc/RpcClient'; -import { METHODS, SUBSCRIPTION_TYPES } from './schema'; -import { NoWalletConnectedError } from '../utils/errors'; -import BrowserConnection from './connection/Browser'; +import { EventEmitter } from 'eventemitter3'; +import AccountRpc from '../account/Rpc.js'; +import { Encoded } from '../utils/encoder.js'; +import { + Accounts, + RPC_VERSION, + Network, + WalletApi, + AeppApi, + NetworkToSelect, +} from './rpc/types.js'; +import RpcClient from './rpc/RpcClient.js'; +import { METHODS, SUBSCRIPTION_TYPES } from './schema.js'; +import { NoWalletConnectedError } from '../utils/errors.js'; +import BrowserConnection from './connection/Browser.js'; interface EventsBase { accountsChange: (accounts: AccountRpc[]) => void; diff --git a/src/aepp-wallet-communication/WalletConnectorFrameWithNode.ts b/src/aepp-wallet-communication/WalletConnectorFrameWithNode.ts index a5c9986ce9..4a954472ab 100644 --- a/src/aepp-wallet-communication/WalletConnectorFrameWithNode.ts +++ b/src/aepp-wallet-communication/WalletConnectorFrameWithNode.ts @@ -1,8 +1,8 @@ -import { Network } from './rpc/types'; -import { RpcConnectionError } from '../utils/errors'; -import Node from '../Node'; -import BrowserConnection from './connection/Browser'; -import WalletConnectorFrameBase from './WalletConnectorFrameBase'; +import { Network } from './rpc/types.js'; +import { RpcConnectionError } from '../utils/errors.js'; +import Node from '../Node.js'; +import BrowserConnection from './connection/Browser.js'; +import WalletConnectorFrameBase from './WalletConnectorFrameBase.js'; interface EventsWithNode { nodeChange: (node: Node) => void; diff --git a/src/aepp-wallet-communication/connection-proxy.ts b/src/aepp-wallet-communication/connection-proxy.ts index 58f485f537..e6fcbc45fb 100644 --- a/src/aepp-wallet-communication/connection-proxy.ts +++ b/src/aepp-wallet-communication/connection-proxy.ts @@ -1,4 +1,4 @@ -import BrowserConnection from './connection/Browser'; +import BrowserConnection from './connection/Browser.js'; /** * Browser connection proxy diff --git a/src/aepp-wallet-communication/connection/Browser.ts b/src/aepp-wallet-communication/connection/Browser.ts index 2a5850195b..053007d2b2 100644 --- a/src/aepp-wallet-communication/connection/Browser.ts +++ b/src/aepp-wallet-communication/connection/Browser.ts @@ -1,4 +1,4 @@ -import { AlreadyConnectedError, NoWalletConnectedError } from '../../utils/errors'; +import { AlreadyConnectedError, NoWalletConnectedError } from '../../utils/errors.js'; /** * Browser connection base interface diff --git a/src/aepp-wallet-communication/connection/BrowserRuntime.ts b/src/aepp-wallet-communication/connection/BrowserRuntime.ts index 6dd6fcbe14..c5848a6a4c 100644 --- a/src/aepp-wallet-communication/connection/BrowserRuntime.ts +++ b/src/aepp-wallet-communication/connection/BrowserRuntime.ts @@ -1,6 +1,6 @@ import { Runtime } from 'webextension-polyfill'; -import BrowserConnection from './Browser'; -import { UnexpectedTsError } from '../../utils/errors'; +import BrowserConnection from './Browser.js'; +import { UnexpectedTsError } from '../../utils/errors.js'; /** * BrowserRuntimeConnection diff --git a/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts b/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts index 28cf44a644..d4d44eb7b9 100644 --- a/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +++ b/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts @@ -1,6 +1,6 @@ -import BrowserConnection from './Browser'; -import { MESSAGE_DIRECTION } from '../schema'; -import { InternalError, RpcConnectionError } from '../../utils/errors'; +import BrowserConnection from './Browser.js'; +import { MESSAGE_DIRECTION } from '../schema.js'; +import { InternalError, RpcConnectionError } from '../../utils/errors.js'; export type ImplPostMessage = Pick< Window, diff --git a/src/aepp-wallet-communication/rpc/RpcClient.ts b/src/aepp-wallet-communication/rpc/RpcClient.ts index 359cfb6ea1..9341c53ffd 100644 --- a/src/aepp-wallet-communication/rpc/RpcClient.ts +++ b/src/aepp-wallet-communication/rpc/RpcClient.ts @@ -1,7 +1,7 @@ -import { RpcError, RpcInternalError, RpcMethodNotFoundError } from '../schema'; -import BrowserConnection from '../connection/Browser'; -import { InvalidRpcMessageError, MissingCallbackError } from '../../utils/errors'; -import { ensureError } from '../../utils/other'; +import { RpcError, RpcInternalError, RpcMethodNotFoundError } from '../schema.js'; +import BrowserConnection from '../connection/Browser.js'; +import { InvalidRpcMessageError, MissingCallbackError } from '../../utils/errors.js'; +import { ensureError } from '../../utils/other.js'; interface JsonRpcRequest { jsonrpc: '2.0'; diff --git a/src/aepp-wallet-communication/rpc/types.ts b/src/aepp-wallet-communication/rpc/types.ts index 06145c0b16..58746352d1 100644 --- a/src/aepp-wallet-communication/rpc/types.ts +++ b/src/aepp-wallet-communication/rpc/types.ts @@ -1,7 +1,7 @@ -import { Encoded } from '../../utils/encoder'; -import { Domain, AciValue } from '../../utils/typed-data'; -import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema'; -import { SignedTx } from '../../apis/node'; +import { Encoded } from '../../utils/encoder.js'; +import { Domain, AciValue } from '../../utils/typed-data.js'; +import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema.js'; +import { SignedTx } from '../../apis/node/index.js'; export interface WalletInfo { id: string; diff --git a/src/aepp-wallet-communication/schema.ts b/src/aepp-wallet-communication/schema.ts index 052d48f809..76e3865343 100644 --- a/src/aepp-wallet-communication/schema.ts +++ b/src/aepp-wallet-communication/schema.ts @@ -1,6 +1,6 @@ // eslint-disable-next-line max-classes-per-file -import { Encoded } from '../utils/encoder'; -import { BaseError, InternalError } from '../utils/errors'; +import { Encoded } from '../utils/encoder.js'; +import { BaseError, InternalError } from '../utils/errors.js'; /** * @category aepp wallet communication diff --git a/src/aepp-wallet-communication/wallet-detector.ts b/src/aepp-wallet-communication/wallet-detector.ts index 861cedf3df..1fa95c6954 100644 --- a/src/aepp-wallet-communication/wallet-detector.ts +++ b/src/aepp-wallet-communication/wallet-detector.ts @@ -1,8 +1,8 @@ -import BrowserConnection from './connection/Browser'; -import BrowserWindowMessageConnection from './connection/BrowserWindowMessage'; -import { MESSAGE_DIRECTION, METHODS } from './schema'; -import { WalletInfo } from './rpc/types'; -import { UnsupportedPlatformError } from '../utils/errors'; +import BrowserConnection from './connection/Browser.js'; +import BrowserWindowMessageConnection from './connection/BrowserWindowMessage.js'; +import { MESSAGE_DIRECTION, METHODS } from './schema.js'; +import { WalletInfo } from './rpc/types.js'; +import { UnsupportedPlatformError } from '../utils/errors.js'; interface Wallet { info: WalletInfo; diff --git a/src/chain.ts b/src/chain.ts index 01e661b6b7..0cdfd8f346 100644 --- a/src/chain.ts +++ b/src/chain.ts @@ -1,8 +1,8 @@ -import { AE_AMOUNT_FORMATS, formatAmount } from './utils/amount-formatter'; -import { isAccountNotFoundError, pause } from './utils/other'; -import { unwrapProxy } from './utils/wrap-proxy'; -import { isNameValid, produceNameId } from './tx/builder/helpers'; -import { AensName, DRY_RUN_ACCOUNT } from './tx/builder/constants'; +import { AE_AMOUNT_FORMATS, formatAmount } from './utils/amount-formatter.js'; +import { isAccountNotFoundError, pause } from './utils/other.js'; +import { unwrapProxy } from './utils/wrap-proxy.js'; +import { isNameValid, produceNameId } from './tx/builder/helpers.js'; +import { AensName, DRY_RUN_ACCOUNT } from './tx/builder/constants.js'; import { AensPointerContextError, DryRunError, @@ -10,10 +10,10 @@ import { TxTimedOutError, TxNotInChainError, InternalError, -} from './utils/errors'; -import Node from './Node'; -import { DryRunResult, DryRunResults, SignedTx } from './apis/node'; -import { decode, encode, Encoded, Encoding } from './utils/encoder'; +} from './utils/errors.js'; +import Node from './Node.js'; +import { DryRunResult, DryRunResults, SignedTx } from './apis/node/index.js'; +import { decode, encode, Encoded, Encoding } from './utils/encoder.js'; /** * @category chain diff --git a/src/channel/Base.ts b/src/channel/Base.ts index f2d63342fa..45f55182d7 100644 --- a/src/channel/Base.ts +++ b/src/channel/Base.ts @@ -1,9 +1,9 @@ import EventEmitter from 'events'; import { w3cwebsocket as W3CWebSocket } from 'websocket'; -import { snakeToPascal } from '../utils/string'; -import { unpackTx } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; -import * as handlers from './handlers'; +import { snakeToPascal } from '../utils/string.js'; +import { unpackTx } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; +import * as handlers from './handlers.js'; import { initialize, enqueueAction, @@ -19,13 +19,13 @@ import { ChannelFsm, ChannelMessage, ChannelEvents, -} from './internal'; -import { ChannelError, IllegalArgumentError } from '../utils/errors'; -import { Encoded } from '../utils/encoder'; -import { TxUnpacked } from '../tx/builder/schema.generated'; -import { EntryTag } from '../tx/builder/entry/constants'; -import { unpackEntry } from '../tx/builder/entry'; -import { EntUnpacked } from '../tx/builder/entry/schema.generated'; +} from './internal.js'; +import { ChannelError, IllegalArgumentError } from '../utils/errors.js'; +import { Encoded } from '../utils/encoder.js'; +import { TxUnpacked } from '../tx/builder/schema.generated.js'; +import { EntryTag } from '../tx/builder/entry/constants.js'; +import { unpackEntry } from '../tx/builder/entry/index.js'; +import { EntUnpacked } from '../tx/builder/entry/schema.generated.js'; function snakeToPascalObjKeys(obj: object): Type { return Object.entries(obj).reduce( diff --git a/src/channel/Contract.ts b/src/channel/Contract.ts index 579cd4673e..8d51b3eacb 100644 --- a/src/channel/Contract.ts +++ b/src/channel/Contract.ts @@ -1,13 +1,13 @@ -import BigNumber from 'bignumber.js'; -import { snakeToPascal } from '../utils/string'; -import { MIN_GAS_PRICE, Tag, AbiVersion, VmVersion } from '../tx/builder/constants'; +import { BigNumber } from 'bignumber.js'; +import { snakeToPascal } from '../utils/string.js'; +import { MIN_GAS_PRICE, Tag, AbiVersion, VmVersion } from '../tx/builder/constants.js'; import { signAndNotify, awaitingCompletion, channelClosed, channelOpen, handleUnexpectedMessage, -} from './handlers'; +} from './handlers.js'; import { notify, call, @@ -18,15 +18,15 @@ import { ChannelFsm, changeState, emit, -} from './internal'; -import { Encoded } from '../utils/encoder'; -import { ContractCallReturnType } from '../apis/node'; -import { ContractCallObject } from '../contract/Contract'; -import Channel from './Base'; -import ChannelSpend from './Spend'; -import { ChannelError, UnexpectedChannelMessageError } from '../utils/errors'; -import { unpackTx } from '../tx/builder'; -import { encodeContractAddress } from '../utils/crypto'; +} from './internal.js'; +import { Encoded } from '../utils/encoder.js'; +import { ContractCallReturnType } from '../apis/node/index.js'; +import { ContractCallObject } from '../contract/Contract.js'; +import Channel from './Base.js'; +import ChannelSpend from './Spend.js'; +import { ChannelError, UnexpectedChannelMessageError } from '../utils/errors.js'; +import { unpackTx } from '../tx/builder/index.js'; +import { encodeContractAddress } from '../utils/crypto.js'; function snakeToPascalObjKeys(obj: object): Type { return Object.entries(obj).reduce( diff --git a/src/channel/Spend.ts b/src/channel/Spend.ts index d9935e7104..217c0d87b3 100644 --- a/src/channel/Spend.ts +++ b/src/channel/Spend.ts @@ -1,4 +1,4 @@ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; import { notify, call, @@ -7,20 +7,20 @@ import { ChannelMessage, ChannelFsm, changeState, -} from './internal'; -import { Encoded } from '../utils/encoder'; -import { pause } from '../utils/other'; -import Channel from './Base'; -import { ChannelConnectionError } from '../utils/errors'; +} from './internal.js'; +import { Encoded } from '../utils/encoder.js'; +import { pause } from '../utils/other.js'; +import Channel from './Base.js'; +import { ChannelConnectionError } from '../utils/errors.js'; import { awaitingCompletion, channelOpen, handleUnexpectedMessage, signAndNotify, -} from './handlers'; -import { EntryTag } from '../tx/builder/entry/constants'; -import { EntUnpacked } from '../tx/builder/entry/schema.generated'; -import { unpackEntry } from '../tx/builder/entry'; +} from './handlers.js'; +import { EntryTag } from '../tx/builder/entry/constants.js'; +import { EntUnpacked } from '../tx/builder/entry/schema.generated.js'; +import { unpackEntry } from '../tx/builder/entry/index.js'; export default class ChannelSpend extends Channel { /** diff --git a/src/channel/handlers.ts b/src/channel/handlers.ts index ce4371569f..ab4a3f137d 100644 --- a/src/channel/handlers.ts +++ b/src/channel/handlers.ts @@ -13,19 +13,19 @@ import { SignTx, ChannelStatus, ChannelEvents, -} from './internal'; -import { unpackTx, buildTx } from '../tx/builder'; -import { decode, Encoded } from '../utils/encoder'; +} from './internal.js'; +import { unpackTx, buildTx } from '../tx/builder/index.js'; +import { decode, Encoded } from '../utils/encoder.js'; import { IllegalArgumentError, InsufficientBalanceError, ChannelConnectionError, UnexpectedChannelMessageError, ChannelError, -} from '../utils/errors'; -import type Channel from './Base'; -import { Tag } from '../tx/builder/constants'; -import { snakeToPascal } from '../utils/string'; +} from '../utils/errors.js'; +import type Channel from './Base.js'; +import { Tag } from '../tx/builder/constants.js'; +import { snakeToPascal } from '../utils/string.js'; export async function appendSignature( tx: Encoded.Transaction, diff --git a/src/channel/internal.ts b/src/channel/internal.ts index c56574f6d6..3d502ca1db 100644 --- a/src/channel/internal.ts +++ b/src/channel/internal.ts @@ -1,9 +1,9 @@ import { default as websocket, ICloseEvent } from 'websocket'; -import BigNumber from 'bignumber.js'; -import type Channel from './Base'; -import JsonBig from '../utils/json-big'; -import { pascalToSnake } from '../utils/string'; -import { Encoded } from '../utils/encoder'; +import { BigNumber } from 'bignumber.js'; +import type Channel from './Base.js'; +import JsonBig from '../utils/json-big.js'; +import { pascalToSnake } from '../utils/string.js'; +import { Encoded } from '../utils/encoder.js'; import { BaseError, ChannelCallError, @@ -12,9 +12,9 @@ import { UnknownChannelStateError, ChannelIncomingMessageError, ChannelError, -} from '../utils/errors'; -import { encodeContractAddress } from '../utils/crypto'; -import { ensureError } from '../utils/other'; +} from '../utils/errors.js'; +import { encodeContractAddress } from '../utils/crypto.js'; +import { ensureError } from '../utils/other.js'; const { w3cwebsocket: W3CWebSocket } = websocket; diff --git a/src/contract/Contract.ts b/src/contract/Contract.ts index d83995b07b..701ade6119 100644 --- a/src/contract/Contract.ts +++ b/src/contract/Contract.ts @@ -6,15 +6,15 @@ */ import { Encoder as Calldata } from '@aeternity/aepp-calldata'; -import { Tag, AensName, DRY_RUN_ACCOUNT } from '../tx/builder/constants'; +import { Tag, AensName, DRY_RUN_ACCOUNT } from '../tx/builder/constants.js'; import { buildContractIdByContractTx, unpackTx, buildTxAsync, BuildTxOptions, buildTxHash, -} from '../tx/builder'; -import { decode, Encoded } from '../utils/encoder'; +} from '../tx/builder/index.js'; +import { decode, Encoded } from '../utils/encoder.js'; import { MissingContractDefError, MissingContractAddressError, @@ -34,16 +34,19 @@ import { InternalError, NoWalletConnectedError, ContractError, -} from '../utils/errors'; -import { hash as calcHash } from '../utils/crypto'; -import { ContractCallObject as NodeContractCallObject, Event as NodeEvent } from '../apis/node'; -import CompilerBase, { Aci } from './compiler/Base'; -import Node from '../Node'; -import { getAccount, getContract, getContractByteCode, resolveName, txDryRun } from '../chain'; -import { sendTransaction, SendTransactionOptions } from '../send-transaction'; -import { TxUnpacked } from '../tx/builder/schema.generated'; -import { Optional, isAccountNotFoundError } from '../utils/other'; -import { isNameValid, produceNameId } from '../tx/builder/helpers'; +} from '../utils/errors.js'; +import { hash as calcHash } from '../utils/crypto.js'; +import { + ContractCallObject as NodeContractCallObject, + Event as NodeEvent, +} from '../apis/node/index.js'; +import CompilerBase, { Aci } from './compiler/Base.js'; +import Node from '../Node.js'; +import { getAccount, getContract, getContractByteCode, resolveName, txDryRun } from '../chain.js'; +import { sendTransaction, SendTransactionOptions } from '../send-transaction.js'; +import { TxUnpacked } from '../tx/builder/schema.generated.js'; +import { Optional, isAccountNotFoundError } from '../utils/other.js'; +import { isNameValid, produceNameId } from '../tx/builder/helpers.js'; type ContractAci = NonNullable; type FunctionAci = ContractAci['functions'][0]; diff --git a/src/contract/compiler/Base.ts b/src/contract/compiler/Base.ts index 289d62d3da..ad5e1e7206 100644 --- a/src/contract/compiler/Base.ts +++ b/src/contract/compiler/Base.ts @@ -1,4 +1,4 @@ -import { Encoded } from '../../utils/encoder'; +import { Encoded } from '../../utils/encoder.js'; interface FunctionAci { arguments: any[]; diff --git a/src/contract/compiler/Cli.ts b/src/contract/compiler/Cli.ts index 9ea429e417..df26ff0eed 100644 --- a/src/contract/compiler/Cli.ts +++ b/src/contract/compiler/Cli.ts @@ -3,11 +3,11 @@ import { tmpdir } from 'os'; import { resolve, dirname, basename } from 'path'; import { mkdir, writeFile, rm } from 'fs/promises'; import { fileURLToPath } from 'url'; -import CompilerBase, { Aci, CompileResult } from './Base'; -import { Encoded } from '../../utils/encoder'; -import { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors'; -import semverSatisfies from '../../utils/semver-satisfies'; -import { ensureError } from '../../utils/other'; +import CompilerBase, { Aci, CompileResult } from './Base.js'; +import { Encoded } from '../../utils/encoder.js'; +import { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors.js'; +import semverSatisfies from '../../utils/semver-satisfies.js'; +import { ensureError } from '../../utils/other.js'; export const getPackagePath = (): string => { const path = dirname(fileURLToPath(import.meta.url)); diff --git a/src/contract/compiler/Http.ts b/src/contract/compiler/Http.ts index 1632bb5c37..374437e540 100644 --- a/src/contract/compiler/Http.ts +++ b/src/contract/compiler/Http.ts @@ -8,11 +8,11 @@ import { Compiler as CompilerApi, ErrorModel, CompilerError as CompilerErrorApi, -} from '../../apis/compiler'; -import { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest'; -import CompilerBase, { Aci, CompileResult } from './Base'; -import { Encoded } from '../../utils/encoder'; -import { CompilerError, NotImplementedError } from '../../utils/errors'; +} from '../../apis/compiler/index.js'; +import { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest.js'; +import CompilerBase, { Aci, CompileResult } from './Base.js'; +import { Encoded } from '../../utils/encoder.js'; +import { CompilerError, NotImplementedError } from '../../utils/errors.js'; type GeneralCompilerError = ErrorModel & { info?: object; diff --git a/src/contract/compiler/HttpNode.ts b/src/contract/compiler/HttpNode.ts index 37d2aa5b49..e430f99165 100644 --- a/src/contract/compiler/HttpNode.ts +++ b/src/contract/compiler/HttpNode.ts @@ -1,8 +1,8 @@ import { readFile } from 'fs/promises'; -import HttpBrowser from './Http'; -import { Aci, CompileResult } from './Base'; -import { Encoded } from '../../utils/encoder'; -import getFileSystem from './getFileSystem'; +import HttpBrowser from './Http.js'; +import { Aci, CompileResult } from './Base.js'; +import { Encoded } from '../../utils/encoder.js'; +import getFileSystem from './getFileSystem.js'; /** * Contract Compiler over HTTP for Nodejs diff --git a/src/contract/compiler/getFileSystem.ts b/src/contract/compiler/getFileSystem.ts index 66fd318a51..e6055dc925 100644 --- a/src/contract/compiler/getFileSystem.ts +++ b/src/contract/compiler/getFileSystem.ts @@ -1,6 +1,6 @@ import { readFile } from 'fs/promises'; import { dirname, resolve, basename } from 'path'; -import { InternalError } from '../../utils/errors'; +import { InternalError } from '../../utils/errors.js'; const defaultIncludes = [ 'List.aes', diff --git a/src/contract/ga.ts b/src/contract/ga.ts index aaec9c25da..4a17898b7b 100644 --- a/src/contract/ga.ts +++ b/src/contract/ga.ts @@ -2,25 +2,25 @@ * Generalized Account module - routines to use generalized account */ -import { ConsensusProtocolVersion, Int, Tag } from '../tx/builder/constants'; +import { ConsensusProtocolVersion, Int, Tag } from '../tx/builder/constants.js'; import { buildContractIdByContractTx, buildTx, buildTxAsync, BuildTxOptions, unpackTx, -} from '../tx/builder'; -import { hash } from '../utils/crypto'; -import { decode, encode, Encoded, Encoding } from '../utils/encoder'; -import { ArgumentError, IllegalArgumentError } from '../utils/errors'; -import { concatBuffers } from '../utils/other'; -import Contract from './Contract'; -import Node from '../Node'; -import { getAccount } from '../chain'; -import { sendTransaction, SendTransactionOptions } from '../send-transaction'; -import CompilerBase from './compiler/Base'; -import { packEntry } from '../tx/builder/entry'; -import { EntryTag } from '../tx/builder/entry/constants'; +} from '../tx/builder/index.js'; +import { hash } from '../utils/crypto.js'; +import { decode, encode, Encoded, Encoding } from '../utils/encoder.js'; +import { ArgumentError, IllegalArgumentError } from '../utils/errors.js'; +import { concatBuffers } from '../utils/other.js'; +import Contract from './Contract.js'; +import Node from '../Node.js'; +import { getAccount } from '../chain.js'; +import { sendTransaction, SendTransactionOptions } from '../send-transaction.js'; +import CompilerBase from './compiler/Base.js'; +import { packEntry } from '../tx/builder/entry/index.js'; +import { EntryTag } from '../tx/builder/entry/constants.js'; /** * Convert current account to GA diff --git a/src/index-browser.ts b/src/index-browser.ts index c69bc2e24f..96a09f2bc9 100644 --- a/src/index-browser.ts +++ b/src/index-browser.ts @@ -16,8 +16,8 @@ export { getContract, getName, resolveName, -} from './chain'; -export { InvalidTxError, sendTransaction } from './send-transaction'; +} from './chain.js'; +export { InvalidTxError, sendTransaction } from './send-transaction.js'; export { isAddressValid, genSalt, @@ -27,17 +27,17 @@ export { verify, messageToHash, verifyMessage, -} from './utils/crypto'; -export { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt'; -export type { Jwt } from './utils/jwt'; -export { toBytes } from './utils/bytes'; +} from './utils/crypto.js'; +export { signJwt, unpackJwt, verifyJwt, isJwt, ensureJwt } from './utils/jwt.js'; +export type { Jwt } from './utils/jwt.js'; +export { toBytes } from './utils/bytes.js'; export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx, -} from './tx/builder'; +} from './tx/builder/index.js'; export { buildContractId, oracleQueryId, @@ -51,7 +51,7 @@ export { computeBidFee, computeAuctionEndBlock, isAuctionName, -} from './tx/builder/helpers'; +} from './tx/builder/helpers.js'; export { MAX_AUTH_FUN_GAS, MIN_GAS_PRICE, @@ -65,70 +65,70 @@ export { AbiVersion, Tag, DRY_RUN_ACCOUNT, -} from './tx/builder/constants'; -export type { Int, AensName } from './tx/builder/constants'; +} from './tx/builder/constants.js'; +export type { Int, AensName } from './tx/builder/constants.js'; // TODO: move to constants -export { ORACLE_TTL_TYPES } from './tx/builder/schema'; -export { DelegationTag } from './tx/builder/delegation/schema'; -export { packDelegation, unpackDelegation } from './tx/builder/delegation'; -export { EntryTag, CallReturnType } from './tx/builder/entry/constants'; -export { packEntry, unpackEntry } from './tx/builder/entry'; +export { ORACLE_TTL_TYPES } from './tx/builder/schema.js'; +export { DelegationTag } from './tx/builder/delegation/schema.js'; +export { packDelegation, unpackDelegation } from './tx/builder/delegation/index.js'; +export { EntryTag, CallReturnType } from './tx/builder/entry/constants.js'; +export { packEntry, unpackEntry } from './tx/builder/entry/index.js'; export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode, -} from './tx/execution-cost'; -export { default as getTransactionSignerAddress } from './tx/transaction-signer'; +} from './tx/execution-cost.js'; +export { default as getTransactionSignerAddress } from './tx/transaction-signer.js'; export { AE_AMOUNT_FORMATS, formatAmount, toAe, toAettos, prefixedAmount, -} from './utils/amount-formatter'; -export { encode, decode, Encoding, Encoded } from './utils/encoder'; -export { hashTypedData, hashDomain, hashJson } from './utils/typed-data'; -export { default as Name } from './aens'; -export { default as Contract } from './contract/Contract'; -export type { ContractMethodsBase } from './contract/Contract'; -export { default as Oracle } from './oracle/Oracle'; -export { default as OracleClient } from './oracle/OracleClient'; -export { spend, transferFunds, payForTransaction } from './spend'; +} from './utils/amount-formatter.js'; +export { encode, decode, Encoding, Encoded } from './utils/encoder.js'; +export { hashTypedData, hashDomain, hashJson } from './utils/typed-data.js'; +export { default as Name } from './aens.js'; +export { default as Contract } from './contract/Contract.js'; +export type { ContractMethodsBase } from './contract/Contract.js'; +export { default as Oracle } from './oracle/Oracle.js'; +export { default as OracleClient } from './oracle/OracleClient.js'; +export { spend, transferFunds, payForTransaction } from './spend.js'; export { createGeneralizedAccount, buildAuthTxHash, buildAuthTxHashByGaMetaTx, -} from './contract/ga'; +} from './contract/ga.js'; -export { default as AeSdkMethods } from './AeSdkMethods'; -export { default as AeSdkBase } from './AeSdkBase'; -export { default as AeSdk } from './AeSdk'; -export { default as AeSdkAepp } from './AeSdkAepp'; -export { default as WalletConnectorFrame } from './aepp-wallet-communication/WalletConnectorFrame'; -export { default as WalletConnectorFrameWithNode } from './aepp-wallet-communication/WalletConnectorFrameWithNode'; -export { default as AeSdkWallet } from './AeSdkWallet'; -export { default as Node } from './Node'; -export { default as verifyTransaction } from './tx/validator'; -export { default as AccountBase } from './account/Base'; -export { default as MemoryAccount } from './account/Memory'; -export { default as AccountMnemonicFactory } from './account/MnemonicFactory'; -export { default as AccountGeneralized } from './account/Generalized'; -export { default as AccountLedger } from './account/Ledger'; -export { default as AccountLedgerFactory } from './account/LedgerFactory'; -export { default as AccountMetamask } from './account/Metamask'; -export { default as AccountMetamaskFactory } from './account/MetamaskFactory'; -export { default as CompilerBase } from './contract/compiler/Base'; -export { default as CompilerHttp } from './contract/compiler/Http'; -export { default as Channel } from './channel/Contract'; +export { default as AeSdkMethods } from './AeSdkMethods.js'; +export { default as AeSdkBase } from './AeSdkBase.js'; +export { default as AeSdk } from './AeSdk.js'; +export { default as AeSdkAepp } from './AeSdkAepp.js'; +export { default as WalletConnectorFrame } from './aepp-wallet-communication/WalletConnectorFrame.js'; +export { default as WalletConnectorFrameWithNode } from './aepp-wallet-communication/WalletConnectorFrameWithNode.js'; +export { default as AeSdkWallet } from './AeSdkWallet.js'; +export { default as Node } from './Node.js'; +export { default as verifyTransaction } from './tx/validator.js'; +export { default as AccountBase } from './account/Base.js'; +export { default as MemoryAccount } from './account/Memory.js'; +export { default as AccountMnemonicFactory } from './account/MnemonicFactory.js'; +export { default as AccountGeneralized } from './account/Generalized.js'; +export { default as AccountLedger } from './account/Ledger.js'; +export { default as AccountLedgerFactory } from './account/LedgerFactory.js'; +export { default as AccountMetamask } from './account/Metamask.js'; +export { default as AccountMetamaskFactory } from './account/MetamaskFactory.js'; +export { default as CompilerBase } from './contract/compiler/Base.js'; +export { default as CompilerHttp } from './contract/compiler/Http.js'; +export { default as Channel } from './channel/Contract.js'; export { default as MiddlewareSubscriber, MiddlewareSubscriberError, MiddlewareSubscriberDisconnected, -} from './MiddlewareSubscriber'; -export { default as Middleware } from './Middleware'; -export { MiddlewarePageMissed } from './utils/MiddlewarePage'; +} from './MiddlewareSubscriber.js'; +export { default as Middleware } from './Middleware.js'; +export { MiddlewarePageMissed } from './utils/MiddlewarePage.js'; -export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy'; +export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy.js'; export { MESSAGE_DIRECTION, WALLET_TYPE, @@ -145,10 +145,10 @@ export { RpcInternalError, RpcMethodNotFoundError, RpcNoNetworkById, -} from './aepp-wallet-communication/schema'; -export { default as walletDetector } from './aepp-wallet-communication/wallet-detector'; -export { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime'; -export { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage'; +} from './aepp-wallet-communication/schema.js'; +export { default as walletDetector } from './aepp-wallet-communication/wallet-detector.js'; +export { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime.js'; +export { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage.js'; export { BaseError, AccountError, @@ -224,4 +224,4 @@ export { AlreadyConnectedError, NoWalletConnectedError, RpcConnectionError, -} from './utils/errors'; +} from './utils/errors.js'; diff --git a/src/index.ts b/src/index.ts index f2c17c52c3..742588bed2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -export * from './index-browser'; +export * from './index-browser.js'; -export { default as CompilerCli } from './contract/compiler/Cli'; -export { default as getFileSystem } from './contract/compiler/getFileSystem'; -export { default as CompilerHttpNode } from './contract/compiler/HttpNode'; +export { default as CompilerCli } from './contract/compiler/Cli.js'; +export { default as getFileSystem } from './contract/compiler/getFileSystem.js'; +export { default as CompilerHttpNode } from './contract/compiler/HttpNode.js'; diff --git a/src/oracle/Oracle.ts b/src/oracle/Oracle.ts index d22748a0d5..b08bc11822 100644 --- a/src/oracle/Oracle.ts +++ b/src/oracle/Oracle.ts @@ -1,12 +1,12 @@ -import { buildTxAsync, BuildTxOptions } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; -import { LogicError, UnexpectedTsError } from '../utils/errors'; -import { decode, encode, Encoded, Encoding } from '../utils/encoder'; -import { _getPollInterval } from '../chain'; -import { sendTransaction, SendTransactionOptions } from '../send-transaction'; -import Node from '../Node'; -import AccountBase from '../account/Base'; -import OracleBase, { OracleQuery, decodeQuery } from './OracleBase'; +import { buildTxAsync, BuildTxOptions } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; +import { LogicError, UnexpectedTsError } from '../utils/errors.js'; +import { decode, encode, Encoded, Encoding } from '../utils/encoder.js'; +import { _getPollInterval } from '../chain.js'; +import { sendTransaction, SendTransactionOptions } from '../send-transaction.js'; +import Node from '../Node.js'; +import AccountBase from '../account/Base.js'; +import OracleBase, { OracleQuery, decodeQuery } from './OracleBase.js'; interface OracleRegisterOptions extends BuildTxOptions, diff --git a/src/oracle/OracleBase.ts b/src/oracle/OracleBase.ts index 53e59e00d9..929b458a90 100644 --- a/src/oracle/OracleBase.ts +++ b/src/oracle/OracleBase.ts @@ -1,5 +1,5 @@ -import { decode, Encoded } from '../utils/encoder'; -import Node from '../Node'; +import { decode, Encoded } from '../utils/encoder.js'; +import Node from '../Node.js'; type OracleQueryNode = Awaited< ReturnType diff --git a/src/oracle/OracleClient.ts b/src/oracle/OracleClient.ts index a2041b6a44..9512822e44 100644 --- a/src/oracle/OracleClient.ts +++ b/src/oracle/OracleClient.ts @@ -1,14 +1,14 @@ -import { pause, Optional } from '../utils/other'; -import { oracleQueryId } from '../tx/builder/helpers'; -import { unpackTx, buildTxAsync, BuildTxOptions } from '../tx/builder'; -import { Tag } from '../tx/builder/constants'; -import { RequestTimedOutError } from '../utils/errors'; -import { decode, Encoded } from '../utils/encoder'; -import { _getPollInterval, getHeight } from '../chain'; -import { sendTransaction } from '../send-transaction'; -import Node from '../Node'; -import AccountBase from '../account/Base'; -import OracleBase from './OracleBase'; +import { pause, Optional } from '../utils/other.js'; +import { oracleQueryId } from '../tx/builder/helpers.js'; +import { unpackTx, buildTxAsync, BuildTxOptions } from '../tx/builder/index.js'; +import { Tag } from '../tx/builder/constants.js'; +import { RequestTimedOutError } from '../utils/errors.js'; +import { decode, Encoded } from '../utils/encoder.js'; +import { _getPollInterval, getHeight } from '../chain.js'; +import { sendTransaction } from '../send-transaction.js'; +import Node from '../Node.js'; +import AccountBase from '../account/Base.js'; +import OracleBase from './OracleBase.js'; interface OracleClientPostQueryOptions extends Optional[1], 'onNode' | 'onAccount'>, diff --git a/src/send-transaction.ts b/src/send-transaction.ts index 5c4207b926..0c976bf0cf 100644 --- a/src/send-transaction.ts +++ b/src/send-transaction.ts @@ -1,12 +1,12 @@ -import verifyTransaction, { ValidatorResult } from './tx/validator'; -import { ensureError } from './utils/other'; -import { TransactionError } from './utils/errors'; -import Node from './Node'; -import { SignedTx } from './apis/node'; -import { Encoded } from './utils/encoder'; -import AccountBase from './account/Base'; -import { buildTxHash } from './tx/builder'; -import { poll, waitForTxConfirm } from './chain'; +import verifyTransaction, { ValidatorResult } from './tx/validator.js'; +import { ensureError } from './utils/other.js'; +import { TransactionError } from './utils/errors.js'; +import Node from './Node.js'; +import { SignedTx } from './apis/node/index.js'; +import { Encoded } from './utils/encoder.js'; +import AccountBase from './account/Base.js'; +import { buildTxHash } from './tx/builder/index.js'; +import { poll, waitForTxConfirm } from './chain.js'; /** * @category exception diff --git a/src/spend.ts b/src/spend.ts index 2bdeaebc06..3c196125ae 100644 --- a/src/spend.ts +++ b/src/spend.ts @@ -1,10 +1,10 @@ -import BigNumber from 'bignumber.js'; -import { getBalance, resolveName } from './chain'; -import { sendTransaction, SendTransactionOptions } from './send-transaction'; -import { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder'; -import { ArgumentError } from './utils/errors'; -import { Encoded } from './utils/encoder'; -import { Tag, AensName } from './tx/builder/constants'; +import { BigNumber } from 'bignumber.js'; +import { getBalance, resolveName } from './chain.js'; +import { sendTransaction, SendTransactionOptions } from './send-transaction.js'; +import { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder/index.js'; +import { ArgumentError } from './utils/errors.js'; +import { Encoded } from './utils/encoder.js'; +import { Tag, AensName } from './tx/builder/constants.js'; // TODO: name verify should not overlap with transaction verify type ResolveNameOptions = Omit[2], 'onNode' | 'verify'>; diff --git a/src/tx/builder/SchemaTypes.ts b/src/tx/builder/SchemaTypes.ts index c4bcc9799a..61f96e8d5d 100644 --- a/src/tx/builder/SchemaTypes.ts +++ b/src/tx/builder/SchemaTypes.ts @@ -1,5 +1,5 @@ -import { Field as OriginalField } from './field-types/interface'; -import { UnionToIntersection } from '../../utils/other'; +import { Field as OriginalField } from './field-types/interface.js'; +import { UnionToIntersection } from '../../utils/other.js'; // TODO: figure out why this override is necessary export interface Field extends OriginalField { diff --git a/src/tx/builder/common.ts b/src/tx/builder/common.ts index c69dd2c1da..1a682e13db 100644 --- a/src/tx/builder/common.ts +++ b/src/tx/builder/common.ts @@ -1,8 +1,13 @@ import { decode as rlpDecode, encode as rlpEncode } from 'rlp'; -import { Field, BinaryData } from './field-types/interface'; -import { ArgumentError, DecodeError, SchemaNotFoundError, InternalError } from '../../utils/errors'; -import { Encoding, Encoded, encode, decode } from '../../utils/encoder'; -import { readInt } from './helpers'; +import { Field, BinaryData } from './field-types/interface.js'; +import { + ArgumentError, + DecodeError, + SchemaNotFoundError, + InternalError, +} from '../../utils/errors.js'; +import { Encoding, Encoded, encode, decode } from '../../utils/encoder.js'; +import { readInt } from './helpers.js'; type Schemas = ReadonlyArray<{ tag: { constValue: number } & Field; diff --git a/src/tx/builder/constants.ts b/src/tx/builder/constants.ts index 5e352fa153..250a8a0696 100644 --- a/src/tx/builder/constants.ts +++ b/src/tx/builder/constants.ts @@ -1,5 +1,5 @@ -import BigNumber from 'bignumber.js'; -import { mapObject } from '../../utils/other'; +import { BigNumber } from 'bignumber.js'; +import { mapObject } from '../../utils/other.js'; export const DRY_RUN_ACCOUNT = { pub: 'ak_11111111111111111111111111111111273Yts', diff --git a/src/tx/builder/delegation/index.ts b/src/tx/builder/delegation/index.ts index bab7010342..352d9158a9 100644 --- a/src/tx/builder/delegation/index.ts +++ b/src/tx/builder/delegation/index.ts @@ -1,7 +1,7 @@ -import { Encoded, Encoding } from '../../../utils/encoder'; -import { packRecord, unpackRecord } from '../common'; -import { DelegationTag, schemas } from './schema'; -import { DlgParams, DlgUnpacked } from './schema.generated'; +import { Encoded, Encoding } from '../../../utils/encoder.js'; +import { packRecord, unpackRecord } from '../common.js'; +import { DelegationTag, schemas } from './schema.js'; +import { DlgParams, DlgUnpacked } from './schema.generated.js'; /** * Pack delegation diff --git a/src/tx/builder/delegation/schema.ts b/src/tx/builder/delegation/schema.ts index 3fba269b6e..ea03f946ad 100644 --- a/src/tx/builder/delegation/schema.ts +++ b/src/tx/builder/delegation/schema.ts @@ -1,8 +1,8 @@ -import SchemaTypes from '../SchemaTypes'; -import address from '../field-types/address'; -import nameId from '../field-types/name-id'; -import shortUIntConst from '../field-types/short-u-int-const'; -import { Encoded, Encoding, decode, encode } from '../../../utils/encoder'; +import SchemaTypes from '../SchemaTypes.js'; +import address from '../field-types/address.js'; +import nameId from '../field-types/name-id.js'; +import shortUIntConst from '../field-types/short-u-int-const.js'; +import { Encoded, Encoding, decode, encode } from '../../../utils/encoder.js'; /** * @category delegation signature diff --git a/src/tx/builder/entry/index.ts b/src/tx/builder/entry/index.ts index 7a18766e9c..9a59ec3c9c 100644 --- a/src/tx/builder/entry/index.ts +++ b/src/tx/builder/entry/index.ts @@ -1,8 +1,8 @@ -import { Encoded, Encoding } from '../../../utils/encoder'; -import { packRecord, unpackRecord } from '../common'; -import { schemas } from './schema'; -import { EntryTag } from './constants'; -import { EntParams, EntUnpacked } from './schema.generated'; +import { Encoded, Encoding } from '../../../utils/encoder.js'; +import { packRecord, unpackRecord } from '../common.js'; +import { schemas } from './schema.js'; +import { EntryTag } from './constants.js'; +import { EntParams, EntUnpacked } from './schema.generated.js'; const encodingTag = [ [EntryTag.CallsMtree, Encoding.CallStateTree], diff --git a/src/tx/builder/entry/schema.ts b/src/tx/builder/entry/schema.ts index d5a8556c2f..4b5f939a07 100644 --- a/src/tx/builder/entry/schema.ts +++ b/src/tx/builder/entry/schema.ts @@ -1,26 +1,26 @@ -import SchemaTypes from '../SchemaTypes'; -import abiVersion from '../field-types/abi-version'; -import address, { idTagToEncoding } from '../field-types/address'; -import array from '../field-types/array'; -import boolean from '../field-types/boolean'; -import coinAmount from '../field-types/coin-amount'; -import ctVersion from '../field-types/ct-version'; -import encoded from '../field-types/encoded'; -import entry from '../field-types/entry'; -import enumeration from '../field-types/enumeration'; -import gasLimit from '../field-types/gas-limit'; -import gasPrice from '../field-types/gas-price'; -import map from '../field-types/map'; -import mptree from '../field-types/mptree'; -import pointers from '../field-types/pointers'; -import raw from '../field-types/raw'; -import shortUInt from '../field-types/short-u-int'; -import shortUIntConst from '../field-types/short-u-int-const'; -import string from '../field-types/string'; -import uInt from '../field-types/u-int'; -import wrapped from '../field-types/wrapped'; -import { Encoded, Encoding } from '../../../utils/encoder'; -import { EntryTag, CallReturnType } from './constants'; +import SchemaTypes from '../SchemaTypes.js'; +import abiVersion from '../field-types/abi-version.js'; +import address, { idTagToEncoding } from '../field-types/address.js'; +import array from '../field-types/array.js'; +import boolean from '../field-types/boolean.js'; +import coinAmount from '../field-types/coin-amount.js'; +import ctVersion from '../field-types/ct-version.js'; +import encoded from '../field-types/encoded.js'; +import entry from '../field-types/entry.js'; +import enumeration from '../field-types/enumeration.js'; +import gasLimit from '../field-types/gas-limit.js'; +import gasPrice from '../field-types/gas-price.js'; +import map from '../field-types/map.js'; +import mptree from '../field-types/mptree.js'; +import pointers from '../field-types/pointers.js'; +import raw from '../field-types/raw.js'; +import shortUInt from '../field-types/short-u-int.js'; +import shortUIntConst from '../field-types/short-u-int-const.js'; +import string from '../field-types/string.js'; +import uInt from '../field-types/u-int.js'; +import wrapped from '../field-types/wrapped.js'; +import { Encoded, Encoding } from '../../../utils/encoder.js'; +import { EntryTag, CallReturnType } from './constants.js'; interface EntryMtreeValueArray { serialize: ( diff --git a/src/tx/builder/field-types/abi-version.ts b/src/tx/builder/field-types/abi-version.ts index 796b30fdee..a8a64efb6d 100644 --- a/src/tx/builder/field-types/abi-version.ts +++ b/src/tx/builder/field-types/abi-version.ts @@ -1,6 +1,6 @@ -import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants'; -import { getProtocolDetails } from './ct-version'; -import Node from '../../../Node'; +import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants.js'; +import { getProtocolDetails } from './ct-version.js'; +import Node from '../../../Node.js'; export default { _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion { diff --git a/src/tx/builder/field-types/address.ts b/src/tx/builder/field-types/address.ts index c83e0f847f..1d9bb9d204 100644 --- a/src/tx/builder/field-types/address.ts +++ b/src/tx/builder/field-types/address.ts @@ -1,7 +1,7 @@ -import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from '../../../utils/errors'; -import { toBytes } from '../../../utils/bytes'; -import { decode, encode, Encoded, Encoding } from '../../../utils/encoder'; -import { isItemOfArray } from '../../../utils/other'; +import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from '../../../utils/errors.js'; +import { toBytes } from '../../../utils/bytes.js'; +import { decode, encode, Encoded, Encoding } from '../../../utils/encoder.js'; +import { isItemOfArray } from '../../../utils/other.js'; /** * Map of prefix to ID tag constant diff --git a/src/tx/builder/field-types/coin-amount.ts b/src/tx/builder/field-types/coin-amount.ts index 03b2eb478e..e91a9a86e0 100644 --- a/src/tx/builder/field-types/coin-amount.ts +++ b/src/tx/builder/field-types/coin-amount.ts @@ -1,6 +1,6 @@ -import uInt from './u-int'; -import { Int } from '../constants'; -import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter'; +import uInt from './u-int.js'; +import { Int } from '../constants.js'; +import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter.js'; export default { ...uInt, diff --git a/src/tx/builder/field-types/ct-version.ts b/src/tx/builder/field-types/ct-version.ts index 782b719604..6347c22dc8 100644 --- a/src/tx/builder/field-types/ct-version.ts +++ b/src/tx/builder/field-types/ct-version.ts @@ -1,5 +1,5 @@ -import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants'; -import Node from '../../../Node'; +import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants.js'; +import Node from '../../../Node.js'; /* * First abi/vm by default diff --git a/src/tx/builder/field-types/encoded.ts b/src/tx/builder/field-types/encoded.ts index dcac9dd27a..41b2772e0e 100644 --- a/src/tx/builder/field-types/encoded.ts +++ b/src/tx/builder/field-types/encoded.ts @@ -1,5 +1,5 @@ -import { decode, encode, Encoded, Encoding } from '../../../utils/encoder'; -import { ArgumentError } from '../../../utils/errors'; +import { decode, encode, Encoded, Encoding } from '../../../utils/encoder.js'; +import { ArgumentError } from '../../../utils/errors.js'; export default function genEncodedField( encoding: E, diff --git a/src/tx/builder/field-types/entry.ts b/src/tx/builder/field-types/entry.ts index 3d4497b3e3..14cad7633b 100644 --- a/src/tx/builder/field-types/entry.ts +++ b/src/tx/builder/field-types/entry.ts @@ -1,6 +1,6 @@ -import { decode, encode, Encoded, Encoding } from '../../../utils/encoder'; -import { EntryTag } from '../entry/constants'; -import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry'; +import { decode, encode, Encoded, Encoding } from '../../../utils/encoder.js'; +import { EntryTag } from '../entry/constants.js'; +import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry/index.js'; export default function genEntryField( tag?: T, diff --git a/src/tx/builder/field-types/enumeration.ts b/src/tx/builder/field-types/enumeration.ts index 0e5887bc4d..5ce924f264 100644 --- a/src/tx/builder/field-types/enumeration.ts +++ b/src/tx/builder/field-types/enumeration.ts @@ -1,5 +1,5 @@ -import { ArgumentError } from '../../../utils/errors'; -import { isItemOfArray } from '../../../utils/other'; +import { ArgumentError } from '../../../utils/errors.js'; +import { isItemOfArray } from '../../../utils/other.js'; export default function genEnumerationField( enm: Enum, diff --git a/src/tx/builder/field-types/fee.ts b/src/tx/builder/field-types/fee.ts index 44cb042c00..8441540b65 100644 --- a/src/tx/builder/field-types/fee.ts +++ b/src/tx/builder/field-types/fee.ts @@ -1,13 +1,13 @@ -import BigNumber from 'bignumber.js'; -import { ArgumentError, IllegalArgumentError } from '../../../utils/errors'; -import { Int, MIN_GAS_PRICE, Tag } from '../constants'; -import uInt from './u-int'; -import coinAmount from './coin-amount'; -import { getCachedIncreasedGasPrice } from './gas-price'; -import { isKeyOfObject } from '../../../utils/other'; -import { decode, Encoded } from '../../../utils/encoder'; -import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index'; -import Node from '../../../Node'; +import { BigNumber } from 'bignumber.js'; +import { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js'; +import { Int, MIN_GAS_PRICE, Tag } from '../constants.js'; +import uInt from './u-int.js'; +import coinAmount from './coin-amount.js'; +import { getCachedIncreasedGasPrice } from './gas-price.js'; +import { isKeyOfObject } from '../../../utils/other.js'; +import { decode, Encoded } from '../../../utils/encoder.js'; +import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js'; +import Node from '../../../Node.js'; const BASE_GAS = 15000; const GAS_PER_BYTE = 20; diff --git a/src/tx/builder/field-types/gas-limit.ts b/src/tx/builder/field-types/gas-limit.ts index 3cd22b3d34..2ea0003de1 100644 --- a/src/tx/builder/field-types/gas-limit.ts +++ b/src/tx/builder/field-types/gas-limit.ts @@ -1,8 +1,8 @@ -import { IllegalArgumentError } from '../../../utils/errors'; -import { Tag, MAX_AUTH_FUN_GAS } from '../constants'; -import shortUInt from './short-u-int'; -import { buildGas } from './fee'; -import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index'; +import { IllegalArgumentError } from '../../../utils/errors.js'; +import { Tag, MAX_AUTH_FUN_GAS } from '../constants.js'; +import shortUInt from './short-u-int.js'; +import { buildGas } from './fee.js'; +import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js'; function calculateGasLimitMax( gasMax: number, diff --git a/src/tx/builder/field-types/gas-price.ts b/src/tx/builder/field-types/gas-price.ts index 271182fd09..046ff0386e 100644 --- a/src/tx/builder/field-types/gas-price.ts +++ b/src/tx/builder/field-types/gas-price.ts @@ -1,9 +1,9 @@ -import BigNumber from 'bignumber.js'; -import coinAmount from './coin-amount'; -import { ArgumentError, IllegalArgumentError } from '../../../utils/errors'; -import { Int, MIN_GAS_PRICE } from '../constants'; -import Node from '../../../Node'; -import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter'; +import { BigNumber } from 'bignumber.js'; +import coinAmount from './coin-amount.js'; +import { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js'; +import { Int, MIN_GAS_PRICE } from '../constants.js'; +import Node from '../../../Node.js'; +import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter.js'; const gasPriceCache: WeakMap = new WeakMap(); diff --git a/src/tx/builder/field-types/map.ts b/src/tx/builder/field-types/map.ts index 565bebbd2d..a897380d68 100644 --- a/src/tx/builder/field-types/map.ts +++ b/src/tx/builder/field-types/map.ts @@ -1,6 +1,6 @@ -import { EntryTag } from '../entry/constants'; -import { encode, Encoding, Encoded, decode } from '../../../utils/encoder'; -import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry'; +import { EntryTag } from '../entry/constants.js'; +import { encode, Encoding, Encoded, decode } from '../../../utils/encoder.js'; +import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry/index.js'; export default function genMapField( encoding: E, diff --git a/src/tx/builder/field-types/mptree.ts b/src/tx/builder/field-types/mptree.ts index 51ec3c1126..074b52c220 100644 --- a/src/tx/builder/field-types/mptree.ts +++ b/src/tx/builder/field-types/mptree.ts @@ -1,6 +1,6 @@ import { encode as rlpEncode, Input } from 'rlp'; -import { EntryTag } from '../entry/constants'; -import { hash } from '../../../utils/crypto'; +import { EntryTag } from '../entry/constants.js'; +import { hash } from '../../../utils/crypto.js'; import { MerkleTreeHashMismatchError, MissingNodeInTreeError, @@ -8,10 +8,10 @@ import { UnexpectedTsError, UnknownNodeLengthError, InternalError, -} from '../../../utils/errors'; -import { decode, encode, Encoded, Encoding } from '../../../utils/encoder'; -import type { unpackEntry } from '../entry'; -import type { EntUnpacked } from '../entry/schema.generated'; +} from '../../../utils/errors.js'; +import { decode, encode, Encoded, Encoding } from '../../../utils/encoder.js'; +import type { unpackEntry } from '../entry/index.js'; +import type { EntUnpacked } from '../entry/schema.generated.js'; enum NodeType { Branch, diff --git a/src/tx/builder/field-types/name-fee.ts b/src/tx/builder/field-types/name-fee.ts index 2ca1d56801..847f228550 100644 --- a/src/tx/builder/field-types/name-fee.ts +++ b/src/tx/builder/field-types/name-fee.ts @@ -1,8 +1,8 @@ -import BigNumber from 'bignumber.js'; -import { getMinimumNameFee } from '../helpers'; -import { InsufficientNameFeeError } from '../../../utils/errors'; -import coinAmount from './coin-amount'; -import { AensName, Int } from '../constants'; +import { BigNumber } from 'bignumber.js'; +import { getMinimumNameFee } from '../helpers.js'; +import { InsufficientNameFeeError } from '../../../utils/errors.js'; +import coinAmount from './coin-amount.js'; +import { AensName, Int } from '../constants.js'; export default { ...coinAmount, diff --git a/src/tx/builder/field-types/name-id.ts b/src/tx/builder/field-types/name-id.ts index 986ae27857..5e4f914d17 100644 --- a/src/tx/builder/field-types/name-id.ts +++ b/src/tx/builder/field-types/name-id.ts @@ -1,7 +1,7 @@ -import { AensName } from '../constants'; -import { produceNameId, isNameValid } from '../helpers'; -import address from './address'; -import { Encoded, Encoding } from '../../../utils/encoder'; +import { AensName } from '../constants.js'; +import { produceNameId, isNameValid } from '../helpers.js'; +import address from './address.js'; +import { Encoded, Encoding } from '../../../utils/encoder.js'; const addressName = address(Encoding.Name); diff --git a/src/tx/builder/field-types/name.ts b/src/tx/builder/field-types/name.ts index 6a8d9e83f1..02727f52e1 100644 --- a/src/tx/builder/field-types/name.ts +++ b/src/tx/builder/field-types/name.ts @@ -1,5 +1,5 @@ -import field from './field'; -import { AensName } from '../constants'; +import field from './field.js'; +import { AensName } from '../constants.js'; export default { /** diff --git a/src/tx/builder/field-types/nonce.ts b/src/tx/builder/field-types/nonce.ts index 3c8e42b56b..0f039fcd02 100644 --- a/src/tx/builder/field-types/nonce.ts +++ b/src/tx/builder/field-types/nonce.ts @@ -1,9 +1,9 @@ -import { isAccountNotFoundError } from '../../../utils/other'; -import shortUInt from './short-u-int'; -import Node from '../../../Node'; -import { ArgumentError } from '../../../utils/errors'; -import { NextNonceStrategy } from '../../../apis/node'; -import { Tag } from '../constants'; +import { isAccountNotFoundError } from '../../../utils/other.js'; +import shortUInt from './short-u-int.js'; +import Node from '../../../Node.js'; +import { ArgumentError } from '../../../utils/errors.js'; +import { NextNonceStrategy } from '../../../apis/node/index.js'; +import { Tag } from '../constants.js'; export default function genNonceField( senderKey: SenderKey, diff --git a/src/tx/builder/field-types/pointers.ts b/src/tx/builder/field-types/pointers.ts index 63b8f0db3b..a3a8734af7 100644 --- a/src/tx/builder/field-types/pointers.ts +++ b/src/tx/builder/field-types/pointers.ts @@ -1,9 +1,9 @@ -import { NamePointer as NamePointerString } from '../../../apis/node'; -import { toBytes } from '../../../utils/bytes'; -import { Encoded, Encoding, decode, encode } from '../../../utils/encoder'; -import { isAddressValid } from '../../../utils/crypto'; -import { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors'; -import address, { AddressEncodings, idTagToEncoding } from './address'; +import { NamePointer as NamePointerString } from '../../../apis/node/index.js'; +import { toBytes } from '../../../utils/bytes.js'; +import { Encoded, Encoding, decode, encode } from '../../../utils/encoder.js'; +import { isAddressValid } from '../../../utils/crypto.js'; +import { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors.js'; +import address, { AddressEncodings, idTagToEncoding } from './address.js'; const ID_TAG = Buffer.from([1]); const DATA_TAG = Buffer.from([2]); diff --git a/src/tx/builder/field-types/query-fee.ts b/src/tx/builder/field-types/query-fee.ts index 57e4bdeff1..aef3aaceae 100644 --- a/src/tx/builder/field-types/query-fee.ts +++ b/src/tx/builder/field-types/query-fee.ts @@ -1,8 +1,8 @@ -import coinAmount from './coin-amount'; -import { Int } from '../constants'; -import Node from '../../../Node'; -import { Encoded } from '../../../utils/encoder'; -import { ArgumentError } from '../../../utils/errors'; +import coinAmount from './coin-amount.js'; +import { Int } from '../constants.js'; +import Node from '../../../Node.js'; +import { Encoded } from '../../../utils/encoder.js'; +import { ArgumentError } from '../../../utils/errors.js'; /** * Oracle query fee diff --git a/src/tx/builder/field-types/short-u-int-const.ts b/src/tx/builder/field-types/short-u-int-const.ts index 04bdf7930b..e4dc8b2e29 100644 --- a/src/tx/builder/field-types/short-u-int-const.ts +++ b/src/tx/builder/field-types/short-u-int-const.ts @@ -1,5 +1,5 @@ -import { ArgumentError } from '../../../utils/errors'; -import shortUInt from './short-u-int'; +import { ArgumentError } from '../../../utils/errors.js'; +import shortUInt from './short-u-int.js'; export default function genShortUIntConstField< Value extends number, diff --git a/src/tx/builder/field-types/short-u-int.ts b/src/tx/builder/field-types/short-u-int.ts index e6f2c570a2..0f91dd61ea 100644 --- a/src/tx/builder/field-types/short-u-int.ts +++ b/src/tx/builder/field-types/short-u-int.ts @@ -1,4 +1,4 @@ -import uInt from './u-int'; +import uInt from './u-int.js'; export default { serialize(value: number): Buffer { diff --git a/src/tx/builder/field-types/string.ts b/src/tx/builder/field-types/string.ts index 2b06a21d51..080fdd8aad 100644 --- a/src/tx/builder/field-types/string.ts +++ b/src/tx/builder/field-types/string.ts @@ -1,4 +1,4 @@ -import { toBytes } from '../../../utils/bytes'; +import { toBytes } from '../../../utils/bytes.js'; export default { serialize(string: string): Buffer { diff --git a/src/tx/builder/field-types/transaction.ts b/src/tx/builder/field-types/transaction.ts index 96374ce70b..8aae79d54e 100644 --- a/src/tx/builder/field-types/transaction.ts +++ b/src/tx/builder/field-types/transaction.ts @@ -1,6 +1,6 @@ -import { decode, encode, Encoded, Encoding } from '../../../utils/encoder'; -import { Tag } from '../constants'; -import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index'; +import { decode, encode, Encoded, Encoding } from '../../../utils/encoder.js'; +import { Tag } from '../constants.js'; +import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js'; export default function genTransactionField( tag?: T, diff --git a/src/tx/builder/field-types/ttl.ts b/src/tx/builder/field-types/ttl.ts index 3045cb5791..6bb320ab85 100644 --- a/src/tx/builder/field-types/ttl.ts +++ b/src/tx/builder/field-types/ttl.ts @@ -1,7 +1,7 @@ -import shortUInt from './short-u-int'; -import Node from '../../../Node'; -import { ArgumentError } from '../../../utils/errors'; -import { _getPollInterval, getHeight } from '../../../chain'; +import shortUInt from './short-u-int.js'; +import Node from '../../../Node.js'; +import { ArgumentError } from '../../../utils/errors.js'; +import { _getPollInterval, getHeight } from '../../../chain.js'; /** * Time to leave diff --git a/src/tx/builder/field-types/u-int.ts b/src/tx/builder/field-types/u-int.ts index 3dbf92054f..0f690f94af 100644 --- a/src/tx/builder/field-types/u-int.ts +++ b/src/tx/builder/field-types/u-int.ts @@ -1,7 +1,7 @@ -import { readInt } from '../helpers'; -import { Int } from '../constants'; -import { ArgumentError } from '../../../utils/errors'; -import { toBytes } from '../../../utils/bytes'; +import { readInt } from '../helpers.js'; +import { Int } from '../constants.js'; +import { ArgumentError } from '../../../utils/errors.js'; +import { toBytes } from '../../../utils/bytes.js'; export default { serialize(value: Int): Buffer { diff --git a/src/tx/builder/field-types/wrapped.ts b/src/tx/builder/field-types/wrapped.ts index 024190c53d..e820f4716b 100644 --- a/src/tx/builder/field-types/wrapped.ts +++ b/src/tx/builder/field-types/wrapped.ts @@ -1,6 +1,6 @@ -import { EntryTag } from '../entry/constants'; -import { encode, Encoding, decode } from '../../../utils/encoder'; -import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry'; +import { EntryTag } from '../entry/constants.js'; +import { encode, Encoding, decode } from '../../../utils/encoder.js'; +import type { unpackEntry as unpackEntryType, packEntry as packEntryType } from '../entry/index.js'; type TagWrapping = | EntryTag.AccountsMtree diff --git a/src/tx/builder/helpers.ts b/src/tx/builder/helpers.ts index b330ed72d9..e4f662617a 100644 --- a/src/tx/builder/helpers.ts +++ b/src/tx/builder/helpers.ts @@ -1,17 +1,17 @@ -import BigNumber from 'bignumber.js'; -import { genSalt, hash } from '../../utils/crypto'; -import { decode, encode, Encoded, Encoding } from '../../utils/encoder'; -import { toBytes } from '../../utils/bytes'; -import { concatBuffers } from '../../utils/other'; +import { BigNumber } from 'bignumber.js'; +import { genSalt, hash } from '../../utils/crypto.js'; +import { decode, encode, Encoded, Encoding } from '../../utils/encoder.js'; +import { toBytes } from '../../utils/bytes.js'; +import { concatBuffers } from '../../utils/other.js'; import { AensName, NAME_BID_RANGES, NAME_BID_TIMEOUT_BLOCKS, NAME_FEE_BID_INCREMENT, NAME_MAX_LENGTH_FEE, -} from './constants'; -import { ceil } from '../../utils/bignumber'; -import { ArgumentError, IllegalBidFeeError } from '../../utils/errors'; +} from './constants.js'; +import { ceil } from '../../utils/bignumber.js'; +import { ArgumentError, IllegalBidFeeError } from '../../utils/errors.js'; /** * JavaScript-based Transaction builder helper function's diff --git a/src/tx/builder/index.ts b/src/tx/builder/index.ts index 9d3e96cb6f..1168554749 100644 --- a/src/tx/builder/index.ts +++ b/src/tx/builder/index.ts @@ -1,13 +1,13 @@ -import { decode, encode, Encoded, Encoding } from '../../utils/encoder'; -import { hash } from '../../utils/crypto'; -import { Field } from './field-types/interface'; -import { txSchema } from './schema'; -import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated'; -import { Tag } from './constants'; -import { buildContractId } from './helpers'; -import { getSchema as getSchemaCommon, packRecord, unpackRecord } from './common'; -import { ArgumentError } from '../../utils/errors'; -import { packEntry, unpackEntry } from './entry'; +import { decode, encode, Encoded, Encoding } from '../../utils/encoder.js'; +import { hash } from '../../utils/crypto.js'; +import { Field } from './field-types/interface.js'; +import { txSchema } from './schema.js'; +import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated.js'; +import { Tag } from './constants.js'; +import { buildContractId } from './helpers.js'; +import { getSchema as getSchemaCommon, packRecord, unpackRecord } from './common.js'; +import { ArgumentError } from '../../utils/errors.js'; +import { packEntry, unpackEntry } from './entry/index.js'; /** * JavaScript-based Transaction builder diff --git a/src/tx/builder/schema.ts b/src/tx/builder/schema.ts index a73592ec84..b71f1433f9 100644 --- a/src/tx/builder/schema.ts +++ b/src/tx/builder/schema.ts @@ -4,38 +4,38 @@ // # RLP version number // # https://github.com/aeternity/protocol/blob/master/serializations.md#binary-serialization -import { Tag } from './constants'; -import SchemaTypes from './SchemaTypes'; -import abiVersion from './field-types/abi-version'; -import address, { idTagToEncoding } from './field-types/address'; -import array from './field-types/array'; -import coinAmount from './field-types/coin-amount'; -import ctVersion from './field-types/ct-version'; -import encoded from './field-types/encoded'; -import entry from './field-types/entry'; -import enumeration from './field-types/enumeration'; -import fee from './field-types/fee'; -import gasLimit from './field-types/gas-limit'; -import gasPrice from './field-types/gas-price'; -import name from './field-types/name'; -import nameFee from './field-types/name-fee'; -import nameId from './field-types/name-id'; -import nonce from './field-types/nonce'; -import pointers from './field-types/pointers'; -import queryFee from './field-types/query-fee'; -import raw from './field-types/raw'; -import shortUInt from './field-types/short-u-int'; -import shortUIntConst from './field-types/short-u-int-const'; -import string from './field-types/string'; -import transaction from './field-types/transaction'; -import ttl from './field-types/ttl'; -import uInt from './field-types/u-int'; -import withDefault from './field-types/with-default'; -import withFormatting from './field-types/with-formatting'; -import { Encoded, Encoding } from '../../utils/encoder'; -import { ArgumentError } from '../../utils/errors'; -import { EntryTag } from './entry/constants'; -import { EntParams, EntUnpacked } from './entry/schema.generated'; +import { Tag } from './constants.js'; +import SchemaTypes from './SchemaTypes.js'; +import abiVersion from './field-types/abi-version.js'; +import address, { idTagToEncoding } from './field-types/address.js'; +import array from './field-types/array.js'; +import coinAmount from './field-types/coin-amount.js'; +import ctVersion from './field-types/ct-version.js'; +import encoded from './field-types/encoded.js'; +import entry from './field-types/entry.js'; +import enumeration from './field-types/enumeration.js'; +import fee from './field-types/fee.js'; +import gasLimit from './field-types/gas-limit.js'; +import gasPrice from './field-types/gas-price.js'; +import name from './field-types/name.js'; +import nameFee from './field-types/name-fee.js'; +import nameId from './field-types/name-id.js'; +import nonce from './field-types/nonce.js'; +import pointers from './field-types/pointers.js'; +import queryFee from './field-types/query-fee.js'; +import raw from './field-types/raw.js'; +import shortUInt from './field-types/short-u-int.js'; +import shortUIntConst from './field-types/short-u-int-const.js'; +import string from './field-types/string.js'; +import transaction from './field-types/transaction.js'; +import ttl from './field-types/ttl.js'; +import uInt from './field-types/u-int.js'; +import withDefault from './field-types/with-default.js'; +import withFormatting from './field-types/with-formatting.js'; +import { Encoded, Encoding } from '../../utils/encoder.js'; +import { ArgumentError } from '../../utils/errors.js'; +import { EntryTag } from './entry/constants.js'; +import { EntParams, EntUnpacked } from './entry/schema.generated.js'; export enum ORACLE_TTL_TYPES { delta = 0, diff --git a/src/tx/execution-cost.ts b/src/tx/execution-cost.ts index 152f188241..952926bfb5 100644 --- a/src/tx/execution-cost.ts +++ b/src/tx/execution-cost.ts @@ -1,11 +1,11 @@ -import { Encoded } from '../utils/encoder'; -import { buildTx, buildTxHash, unpackTx } from './builder'; -import { Tag } from './builder/constants'; -import { verify } from '../utils/crypto'; -import { getBufferToSign } from '../account/Memory'; -import { IllegalArgumentError, InternalError, TransactionError } from '../utils/errors'; -import Node from '../Node'; -import getTransactionSignerAddress from './transaction-signer'; +import { Encoded } from '../utils/encoder.js'; +import { buildTx, buildTxHash, unpackTx } from './builder/index.js'; +import { Tag } from './builder/constants.js'; +import { verify } from '../utils/crypto.js'; +import { getBufferToSign } from '../account/Memory.js'; +import { IllegalArgumentError, InternalError, TransactionError } from '../utils/errors.js'; +import Node from '../Node.js'; +import getTransactionSignerAddress from './transaction-signer.js'; /** * Calculates the cost of transaction execution diff --git a/src/tx/transaction-signer.ts b/src/tx/transaction-signer.ts index aaf9f8c5fa..fa4024443a 100644 --- a/src/tx/transaction-signer.ts +++ b/src/tx/transaction-signer.ts @@ -1,7 +1,7 @@ -import { Encoded } from '../utils/encoder'; -import { buildTx, getSchema, unpackTx } from './builder'; -import { Tag } from './builder/constants'; -import { TransactionError, UnexpectedTsError } from '../utils/errors'; +import { Encoded } from '../utils/encoder.js'; +import { buildTx, getSchema, unpackTx } from './builder/index.js'; +import { Tag } from './builder/constants.js'; +import { TransactionError, UnexpectedTsError } from '../utils/errors.js'; /** * Returns account address that signed a transaction diff --git a/src/tx/validator.ts b/src/tx/validator.ts index 326d047c99..2f9f68ddbd 100644 --- a/src/tx/validator.ts +++ b/src/tx/validator.ts @@ -1,17 +1,17 @@ import { RestError } from '@azure/core-rest-pipeline'; -import { hash, isAddressValid, verify } from '../utils/crypto'; -import { TxUnpacked } from './builder/schema.generated'; -import { CtVersion, ProtocolToVmAbi } from './builder/field-types/ct-version'; -import { Tag, ConsensusProtocolVersion } from './builder/constants'; -import { buildTx, unpackTx } from './builder'; -import { concatBuffers, isAccountNotFoundError } from '../utils/other'; -import { Encoded, Encoding, decode } from '../utils/encoder'; -import Node from '../Node'; -import { Account } from '../apis/node'; -import { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest'; -import { UnexpectedTsError } from '../utils/errors'; -import getTransactionSignerAddress from './transaction-signer'; -import { getExecutionCostUsingNode } from './execution-cost'; +import { hash, isAddressValid, verify } from '../utils/crypto.js'; +import { TxUnpacked } from './builder/schema.generated.js'; +import { CtVersion, ProtocolToVmAbi } from './builder/field-types/ct-version.js'; +import { Tag, ConsensusProtocolVersion } from './builder/constants.js'; +import { buildTx, unpackTx } from './builder/index.js'; +import { concatBuffers, isAccountNotFoundError } from '../utils/other.js'; +import { Encoded, Encoding, decode } from '../utils/encoder.js'; +import Node from '../Node.js'; +import { Account } from '../apis/node/index.js'; +import { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest.js'; +import { UnexpectedTsError } from '../utils/errors.js'; +import getTransactionSignerAddress from './transaction-signer.js'; +import { getExecutionCostUsingNode } from './execution-cost.js'; export interface ValidatorResult { message: string; diff --git a/src/utils/MiddlewarePage.ts b/src/utils/MiddlewarePage.ts index 2c8d3cdc30..0ef59a483f 100644 --- a/src/utils/MiddlewarePage.ts +++ b/src/utils/MiddlewarePage.ts @@ -1,6 +1,6 @@ /* eslint-disable max-classes-per-file */ -import type Middleware from '../Middleware'; -import { BaseError } from './errors'; +import type Middleware from '../Middleware.js'; +import { BaseError } from './errors.js'; export interface MiddlewareRawPage { data: unknown[]; diff --git a/src/utils/amount-formatter.ts b/src/utils/amount-formatter.ts index 2f520a9fb6..76f9e71ac9 100644 --- a/src/utils/amount-formatter.ts +++ b/src/utils/amount-formatter.ts @@ -1,6 +1,6 @@ -import BigNumber from 'bignumber.js'; -import { isBigNumber } from './bignumber'; -import { ArgumentError } from './errors'; +import { BigNumber } from 'bignumber.js'; +import { isBigNumber } from './bignumber.js'; +import { ArgumentError } from './errors.js'; export enum AE_AMOUNT_FORMATS { AE = 'ae', diff --git a/src/utils/autorest.ts b/src/utils/autorest.ts index 06f061fd00..3b1af06381 100644 --- a/src/utils/autorest.ts +++ b/src/utils/autorest.ts @@ -5,9 +5,9 @@ import { OperationOptions, createSerializer as createSerializerOrig, } from '@azure/core-client'; -import { pause } from './other'; -import semverSatisfies from './semver-satisfies'; -import { InternalError, UnexpectedTsError, UnsupportedVersionError } from './errors'; +import { pause } from './other.js'; +import semverSatisfies from './semver-satisfies.js'; +import { InternalError, UnexpectedTsError, UnsupportedVersionError } from './errors.js'; const bigIntPrefix = '_sdk-big-int-'; diff --git a/src/utils/bignumber.ts b/src/utils/bignumber.ts index e48273b854..ad1ffb0597 100644 --- a/src/utils/bignumber.ts +++ b/src/utils/bignumber.ts @@ -1,7 +1,7 @@ /** * Big Number Helpers */ -import BigNumber from 'bignumber.js'; +import { BigNumber } from 'bignumber.js'; /** * Check if value is BigNumber, Number, BigInt or number string representation diff --git a/src/utils/bytes.ts b/src/utils/bytes.ts index dbbdeeadbc..edfdc98498 100644 --- a/src/utils/bytes.ts +++ b/src/utils/bytes.ts @@ -1,5 +1,5 @@ -import BigNumber from 'bignumber.js'; -import { NoSerializerFoundError, TypeError } from './errors'; +import { BigNumber } from 'bignumber.js'; +import { NoSerializerFoundError, TypeError } from './errors.js'; /** * Convert string, number, or BigNumber to byte array diff --git a/src/utils/crypto.ts b/src/utils/crypto.ts index 551ffe63d2..5b11da5722 100644 --- a/src/utils/crypto.ts +++ b/src/utils/crypto.ts @@ -4,9 +4,9 @@ import nacl from 'tweetnacl'; import { blake2b } from 'blakejs/blake2b.js'; import { encode as varuintEncode } from 'varuint-bitcoin'; -import { concatBuffers, isItemOfArray } from './other'; -import { decode, encode, Encoded, Encoding } from './encoder'; -import { ArgumentError } from './errors'; +import { concatBuffers, isItemOfArray } from './other.js'; +import { decode, encode, Encoded, Encoding } from './encoder.js'; +import { ArgumentError } from './errors.js'; /** * Check if address is valid diff --git a/src/utils/encoder.ts b/src/utils/encoder.ts index 4cb2aac17c..6b0d52bdbb 100644 --- a/src/utils/encoder.ts +++ b/src/utils/encoder.ts @@ -2,10 +2,10 @@ import bs58 from 'bs58'; // js extension is required for mjs build, not importing the whole package to reduce bundle size // eslint-disable-next-line import/extensions import Sha256 from 'sha.js/sha256.js'; -import { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from './errors'; -import { concatBuffers, isKeyOfObject } from './other'; -import * as Encoded from './encoder-types'; -import { Encoding } from './encoder-types'; +import { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from './errors.js'; +import { concatBuffers, isKeyOfObject } from './other.js'; +import * as Encoded from './encoder-types.js'; +import { Encoding } from './encoder-types.js'; export { Encoded, Encoding }; diff --git a/src/utils/errors.ts b/src/utils/errors.ts index 8eb69db460..bddbeac000 100644 --- a/src/utils/errors.ts +++ b/src/utils/errors.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line max-classes-per-file -import BigNumber from 'bignumber.js'; -import { AensName, Int } from '../tx/builder/constants'; -import * as Encoded from './encoder-types'; +import { BigNumber } from 'bignumber.js'; +import { AensName, Int } from '../tx/builder/constants.js'; +import * as Encoded from './encoder-types.js'; /** * aepp-sdk originated error diff --git a/src/utils/json-big.ts b/src/utils/json-big.ts index fee5abc95a..aefd7b9a48 100644 --- a/src/utils/json-big.ts +++ b/src/utils/json-big.ts @@ -1,6 +1,6 @@ import JsonBig from 'json-bigint'; -import BigNumber from 'bignumber.js'; -import { mapObject } from './other'; +import { BigNumber } from 'bignumber.js'; +import { mapObject } from './other.js'; const jsonBig = JsonBig({ storeAsString: true }); diff --git a/src/utils/jwt.ts b/src/utils/jwt.ts index a9f719b6fa..36406de0f2 100644 --- a/src/utils/jwt.ts +++ b/src/utils/jwt.ts @@ -1,8 +1,8 @@ import canonicalize from 'canonicalize'; -import AccountBase from '../account/Base'; -import { Encoded, Encoding, decode, encode } from './encoder'; -import { verify } from './crypto'; -import { ArgumentError, InvalidSignatureError } from './errors'; +import AccountBase from '../account/Base.js'; +import { Encoded, Encoding, decode, encode } from './encoder.js'; +import { verify } from './crypto.js'; +import { ArgumentError, InvalidSignatureError } from './errors.js'; // TODO: use Buffer.from(data, 'base64url') after solving https://github.com/feross/buffer/issues/309 const toBase64Url = (data: Buffer | Uint8Array | string): string => diff --git a/src/utils/typed-data.ts b/src/utils/typed-data.ts index 1cde553545..bc14041747 100644 --- a/src/utils/typed-data.ts +++ b/src/utils/typed-data.ts @@ -1,8 +1,8 @@ import { TypeResolver, ContractByteArrayEncoder } from '@aeternity/aepp-calldata'; import canonicalize from 'canonicalize'; -import { Encoded, decode } from './encoder'; -import { hash, messagePrefixLength } from './crypto'; -import { concatBuffers } from './other'; +import { Encoded, decode } from './encoder.js'; +import { hash, messagePrefixLength } from './crypto.js'; +import { concatBuffers } from './other.js'; /** * Hashes arbitrary object, can be used to inline the aci hash to contract source code diff --git a/src/utils/wrap-proxy.ts b/src/utils/wrap-proxy.ts index 886920db3a..d996568e50 100644 --- a/src/utils/wrap-proxy.ts +++ b/src/utils/wrap-proxy.ts @@ -1,4 +1,4 @@ -import { ArgumentError } from './errors'; +import { ArgumentError } from './errors.js'; export function wrapWithProxy( valueCb: () => Value, diff --git a/tooling/autorest/postprocessing.js b/tooling/autorest/postprocessing.js index 7dfdf9bbbf..df9905391d 100644 --- a/tooling/autorest/postprocessing.js +++ b/tooling/autorest/postprocessing.js @@ -15,6 +15,7 @@ const nodeBigIntPropertyNames = [ 'gasPrice', 'minGasPrice', 'deposit', + 'subunitsPerUnit', ]; const middlewareBigIntPropertyNames = [ @@ -67,130 +68,131 @@ function toTsType(types) { } const module = process.argv.at(-1); -await Promise.all([ - (async () => { - const path = `./src/apis/${module}/${module}.ts`; - let content = await fs.promises.readFile(path, { encoding: 'utf-8' }); - content = content.replace(/ {2}\$host: string;/, ' readonly $host: string;'); - if (module === 'node' || module === 'middleware') { - content = `import { createSerializer } from "../../utils/autorest";\n${content}`; - content = content.replace('coreClient.createSerializer', 'createSerializer'); +await Promise.all( + ['models/index', 'models/mappers', 'models/parameters', 'index', module].map(async (name) => { + const path = `./src/apis/${module}/${name}.ts`; + let content; + try { + content = await fs.promises.readFile(path, { encoding: 'utf-8' }); + } catch (error) { + if (error.code === 'ENOENT') return; + throw error; } - if (module === 'middleware') { - const operationSpecNames = [ - ...content.matchAll(/const (\w+OperationSpec): coreClient\.OperationSpec = {/g), - ].map(([, nm]) => nm); - content = `${content}\nexport const operationSpecs = [\n ${operationSpecNames.join(',\n ')},\n] as const;\n`; - - const parts = content.split('__sdk__'); - content = parts.shift(); - while (parts.length) { - const idx = content.lastIndexOf('@param ') + '@param '.length; - const name = content.slice(idx, idx + content.slice(idx).indexOf(' ')); - const types = parts.shift(); - const needle = `${name}: string`; - const replaceIdx = parts.findIndex((part) => part.includes(needle)); - parts[replaceIdx] = parts[replaceIdx].replace(needle, `${name}: ${toTsType(types)}`); - content += parts.shift(); + // TODO: remove after solving https://github.com/Azure/autorest.typescript/issues/1955 + content = content.replaceAll(/ from "\.(.*)\/models";/g, ' from ".$1/models/index";'); + content = content.replaceAll(/ from "\.(.+)";/g, ' from ".$1.js";'); + + if (name === module) { + content = content.replace(/ {2}\$host: string;/, ' readonly $host: string;'); + + if (module === 'node' || module === 'middleware') { + content = `import { createSerializer } from "../../utils/autorest.js";\n${content}`; + content = content.replace('coreClient.createSerializer', 'createSerializer'); + } + + if (module === 'middleware') { + const operationSpecNames = [ + ...content.matchAll(/const (\w+OperationSpec): coreClient\.OperationSpec = {/g), + ].map(([, nm]) => nm); + content = `${content}\nexport const operationSpecs = [\n ${operationSpecNames.join(',\n ')},\n] as const;\n`; + + const parts = content.split('__sdk__'); + content = parts.shift(); + while (parts.length) { + const idx = content.lastIndexOf('@param ') + '@param '.length; + const name = content.slice(idx, idx + content.slice(idx).indexOf(' ')); + const types = parts.shift(); + const needle = `${name}: string`; + const replaceIdx = parts.findIndex((part) => part.includes(needle)); + parts[replaceIdx] = parts[replaceIdx].replace(needle, `${name}: ${toTsType(types)}`); + content += parts.shift(); + } } } - await fs.promises.writeFile(path, content); - })(), - ...(module === 'node' || module === 'middleware' - ? [ - (async () => { - const path = `./src/apis/${module}/models/index.ts`; - let content = await fs.promises.readFile(path, { encoding: 'utf-8' }); - - (module === 'node' ? nodeBigIntPropertyNames : middlewareBigIntPropertyNames).forEach( - (property) => { - content = content.replaceAll( - new RegExp(`(${property}[?]?:) number`, 'g'), - '$1 bigint', - ); - }, + if (module === 'node' || module === 'middleware') { + if (name === 'models/index') { + (module === 'node' ? nodeBigIntPropertyNames : middlewareBigIntPropertyNames).forEach( + (property) => { + content = content.replaceAll(new RegExp(`(${property}[?]?:) number`, 'g'), '$1 bigint'); + }, + ); + + if (module === 'node') { + /* eslint-disable no-template-curly-in-string */ + content = content.replaceAll(/(txHash\??:) string/g, '$1 `th_${string}`'); + content = content.replaceAll(/(bytecode\??:) string/g, '$1 `cb_${string}`'); + /* eslint-enable no-template-curly-in-string */ + content = content.replaceAll('topics: number[]', 'topics: bigint[]'); + } + + if (module === 'middleware') { + content = `import { MiddlewarePage } from "../../../utils/MiddlewarePage.js";\n${content}`; + content = content.replace(/export interface PaginatedResponse {.*?}\n\n/gs, ''); + content = content.replace( + /extends PaginatedResponse,(\s+)(\w+) {}/gs, + 'extends $2,$1PaginatedResponse {}', ); - - if (module === 'node') { - /* eslint-disable no-template-curly-in-string */ - content = content.replaceAll(/(txHash\??:) string/g, '$1 `th_${string}`'); - content = content.replaceAll(/(bytecode\??:) string/g, '$1 `cb_${string}`'); - /* eslint-enable no-template-curly-in-string */ - content = content.replaceAll('topics: number[]', 'topics: bigint[]'); - } - - if (module === 'middleware') { - content = `import { MiddlewarePage } from "../../../utils/MiddlewarePage";\n${content}`; - content = content.replace(/export interface PaginatedResponse {.*?}\n\n/gs, ''); - content = content.replace( - /extends PaginatedResponse,(\s+)(\w+) {}/gs, - 'extends $2,$1PaginatedResponse {}', + const responseRe = /export interface (\w+)\s+extends (\w+),\s+PaginatedResponse {}/s; + while (content.match(responseRe)) { + const [response, responseTypeName, dataTypeName] = content.match(responseRe); + const regExp = new RegExp( + String.raw`export interface ${dataTypeName} {\s+data: (\w+)\[\];\s+}\n\n`, + 's', ); - const responseRe = /export interface (\w+)\s+extends (\w+),\s+PaginatedResponse {}/s; - while (content.match(responseRe)) { - const [response, responseTypeName, dataTypeName] = content.match(responseRe); - const regExp = new RegExp( - String.raw`export interface ${dataTypeName} {\s+data: (\w+)\[\];\s+}\n\n`, - 's', - ); - const match = content.match(regExp); - if (match == null) throw new Error(`Can't find interface ${dataTypeName}`); - const [, arrayItemTypeName] = match; - content = content.replace(new RegExp(regExp, 'g'), ''); - content = content.replace(response, ''); - content = content.replace(responseTypeName, `MiddlewarePage<${arrayItemTypeName}>`); - } - if (content.includes('PaginatedResponse')) { - throw new Error('Not all PaginatedResponse instances removed'); - } - - const parts = content.split('__sdk__'); - content = parts.shift(); - while (parts.length) { - const types = parts.shift(); - content += parts.shift().replace(': string', `: ${toTsType(types)}`); - } + const match = content.match(regExp); + if (match == null) throw new Error(`Can't find interface ${dataTypeName}`); + const [, arrayItemTypeName] = match; + content = content.replace(new RegExp(regExp, 'g'), ''); + content = content.replace(response, ''); + content = content.replace(responseTypeName, `MiddlewarePage<${arrayItemTypeName}>`); + } + if (content.includes('PaginatedResponse')) { + throw new Error('Not all PaginatedResponse instances removed'); } - await fs.promises.writeFile(path, content); - })(), - (async () => { - const path = `./src/apis/${module}/models/mappers.ts`; - let content = await fs.promises.readFile(path, { encoding: 'utf-8' }); - - (module === 'node' ? nodeBigIntPropertyNames : middlewareBigIntPropertyNames).forEach( - (property) => { - content = content.replace( - new RegExp( - `${property}: \\{` + - '(\\s+constraints: \\{.+?\\},)?' + - '(\\s+serializedName: "\\w+",)' + - '(\\s+required: true,)?' + - '(\\s+type: \\{)' + - '(\\s+)name: "Number",', - 'mgs', - ), - `${property}: {$1$2$3$4` + - '$5// @ts-expect-error we are extending autorest with BigInt support' + - '$5name: "BigInt",', - ); - }, - ); + const parts = content.split('__sdk__'); + content = parts.shift(); + while (parts.length) { + const types = parts.shift(); + content += parts.shift().replace(': string', `: ${toTsType(types)}`); + } + } + } - if (module === 'node') { + if (name === 'models/mappers') { + (module === 'node' ? nodeBigIntPropertyNames : middlewareBigIntPropertyNames).forEach( + (property) => { content = content.replace( - /topics: (.+?name: "Sequence".+?)(\s+)name: "Number",/gms, - 'topics: $1' + - '$2// @ts-expect-error we are extending autorest with BigInt support' + - '$2name: "BigInt",', + new RegExp( + `${property}: \\{` + + '(\\s+constraints: \\{.+?\\},)?' + + '(\\s+serializedName: "\\w+",)' + + '(\\s+required: true,)?' + + '(\\s+type: \\{)' + + '(\\s+)name: "Number",', + 'mgs', + ), + `${property}: {$1$2$3$4` + + '$5// @ts-expect-error we are extending autorest with BigInt support' + + '$5name: "BigInt",', ); - } + }, + ); + + if (module === 'node') { + content = content.replace( + /topics: (.+?name: "Sequence".+?)(\s+)name: "Number",/gms, + 'topics: $1' + + '$2// @ts-expect-error we are extending autorest with BigInt support' + + '$2name: "BigInt",', + ); + } + } + } - await fs.promises.writeFile(path, content); - })(), - ] - : []), -]); + await fs.promises.writeFile(path, content); + }), +); diff --git a/tooling/generate-schema.ts b/tooling/generate-schema.ts index 8a6f55a3af..d1609434a0 100755 --- a/tooling/generate-schema.ts +++ b/tooling/generate-schema.ts @@ -75,7 +75,7 @@ function generate( ), ]), ), - factory.createStringLiteral('./schema'), + factory.createStringLiteral('./schema.js'), undefined, ), factory.createImportDeclaration( @@ -91,7 +91,7 @@ function generate( ), ]), ), - factory.createStringLiteral(tagInConstants ? './constants' : './schema'), + factory.createStringLiteral(tagInConstants ? './constants.js' : './schema.js'), undefined, ), ...schemas diff --git a/webpack.config.js b/webpack.config.js index fc1c06370a..f4d2db04bc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -27,6 +27,7 @@ function configure(filename, opts = {}) { }, resolve: { extensions: ['.ts', '.js'], + extensionAlias: { '.js': ['.ts', '.js'] }, fallback: isNode ? {} : {