Skip to content

Commit

Permalink
Merge pull request #1800 from aeternity/release/13.0.1
Browse files Browse the repository at this point in the history
Release 13.0.1
  • Loading branch information
davidyuk authored Apr 25, 2023
2 parents 79a2c5a + 4a554a2 commit 26014b7
Show file tree
Hide file tree
Showing 32 changed files with 97 additions and 95 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
sudo apt install --allow-downgrades ./esl-erlang_25.0.4-1~ubuntu~jammy_amd64.deb
- uses: actions/checkout@v2
with:
fetch-depth: 0
fetch-depth: 100
- uses: actions/setup-node@v2
with:
node-version: 18.x
Expand All @@ -21,16 +21,11 @@ jobs:
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- name: Run Commitlint
if: github.event_name == 'pull_request'
env:
EVENT_TYPE: ${{ github.event_name }}
HEAD: ${{ github.event.pull_request.head.sha }}
BASE: ${{ github.event.pull_request.base.sha }}
run: |
if [ "$EVENT_TYPE" = "push" ]; then
npx commitlint --from HEAD~${{ github.event.push.commits }} --to HEAD --verbose
else
npx commitlint --from $BASE --to $HEAD --verbose
fi
run: npx commitlint --from $BASE --to $HEAD --verbose
- run: npm run lint
- run: docker-compose up -d
- name: Ensure that node is running
Expand Down
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [13.0.1](https://github.com/aeternity/aepp-sdk-js/compare/v13.0.0...v13.0.1) (2023-04-24)


### Bug Fixes

* **contract:** return type of call/deploy on chain ([c493707](https://github.com/aeternity/aepp-sdk-js/commit/c49370756fa3ed3a6f37bad2cefcbbd858ff94ee))
* export of `prefixedAmount` helper ([9b3f68f](https://github.com/aeternity/aepp-sdk-js/commit/9b3f68f99b3943c42c4639c3a247ee9881229d18))

## [13.0.0](https://github.com/aeternity/aepp-sdk-js/compare/v13.0.0-beta.0...v13.0.0) (2023-04-06)


Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ This may be done in `tsconfig.json`:
```
SDK uses modern features available since [email protected]. Though SDK is still compatible with [email protected] and above using types generated separately, but these types are less accurate.

Ensure that you have `strictFunctionTypes` option not enabled (as it is in VS code and `ts-node` by default), otherwise some of SDK types won't work correctly (see [#1793](https://github.com/aeternity/aepp-sdk-js/issues/1793)).

### Vue CLI@4
SDK checks are not working correctly because CLI picks both ESM and CJS versions of `autorest`
dependencies. To fix this, you need to specify aliases in `vue.config.js`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aeternity/aepp-sdk",
"version": "13.0.0",
"version": "13.0.1",
"description": "SDK for the æternity blockchain",
"main": "dist/aepp-sdk.js",
"types": "es/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/contract/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type TxData = Awaited<ReturnType<typeof sendTransaction>>;
interface SendAndProcessReturnType {
result?: ContractCallObject;
hash: TxData['hash'];
tx: TxUnpacked & { tag: Tag.ContractCallTx | Tag.ContractCreateTx };
tx: TxUnpacked & { tag: Tag.SignedTx | Tag.ContractCallTx | Tag.ContractCreateTx };
txData: TxData;
rawTx: Encoded.Transaction;
}
Expand Down
17 changes: 17 additions & 0 deletions src/tx/execution-cost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ import getTransactionSignerAddress from './transaction-signer';
* Calculates the cost of transaction execution
* Provides an upper cost of contract-call-related transactions because of `gasLimit`.
* Also assumes that oracle query fee is 0 unless it is provided in options.
*
* The idea is that if you need to show transaction details with some accuracy you can define
* expense fields that you want to show separately. And to show `getExecutionCost` result as a fee,
* subtracting all fields shown separately.
*
* @example
* ```vue
* <template>
* Amount: {{ txUnpacked.amount }}
* Name fee: {{ txUnpacked.nameFee }}
* Other fees: {{ getExecutionCost(txEncoded) - txUnpacked.amount - txUnpacked.nameFee }}
* </template>
* ```
*
* Doing this way you won't worry to show wrong fee for a transaction you may not support. Because
* the SDK calculates the overall price of any transaction on its side.
*
* @param transaction - Transaction to calculate the cost of
* @param innerTx - Should be provided if transaction wrapped with Tag.PayingForTx
* @param gasUsed - Amount of gas actually used to make calculation more accurate
Expand Down
20 changes: 0 additions & 20 deletions src/typings/@aeternity__aepp-calldata/index.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/amount-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const getNearestPrefix = (exponent: number): Prefix => prefixes.reduce((p, n) =>
const getLowerBoundPrefix = (exponent: number): Prefix => prefixes
.find((p) => p.magnitude <= exponent) ?? prefixes[prefixes.length - 1];

export default (rawValue: string | number | BigNumber): string => {
export const prefixedAmount = (rawValue: string | number | BigNumber): string => {
const value: BigNumber = new BigNumber(rawValue);

const exp = value.e ?? 0;
Expand Down
4 changes: 3 additions & 1 deletion test/environment/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const aeSdk = new AeSdk({
console.log('Height:', await aeSdk.getHeight());
console.log('Instanceof works correctly for nodes pool', aeSdk.pool instanceof Map);

const contract = await aeSdk.initializeContract({ sourceCode: contractSourceCode });
const contract = await aeSdk.initializeContract<{
getArg: (x: Map<string, number | bigint | string>) => Map<string, bigint>;
}>({ sourceCode: contractSourceCode });
const deployInfo = await contract.$deploy([]);
console.log('Contract deployed at', deployInfo.address);
const map = new Map([['foo', 42], ['bar', 43]]);
Expand Down
5 changes: 2 additions & 3 deletions test/integration/account-generalized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import {
Tag,
unpackTx,
buildTx,
Contract,
Contract, ContractMethodsBase,
MIN_GAS_PRICE,
Encoded,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';
import { ContractMethodsBase } from '../../src/contract/Contract';
import { ensureEqual } from '../utils';

const sourceCode = `contract BlindAuth =
Expand Down
8 changes: 7 additions & 1 deletion test/integration/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
AeSdk, MemoryAccount,
generateKeyPair, AE_AMOUNT_FORMATS,
UnavailableAccountError, TypeError, ArgumentError, UnexpectedTsError,
encode, Encoding, Encoded,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';

describe('Accounts', () => {
let aeSdk: AeSdk;
Expand Down Expand Up @@ -121,6 +121,12 @@ describe('Accounts', () => {
ret.tx.should.include({ amount: bigAmount, recipientId: publicKey });
});

it('spends with a payload', async () => {
const payload = encode(Buffer.from([1, 2, 3, 4]), Encoding.Bytearray);
const { tx } = await aeSdk.spend(1, receiver.address, { payload });
expect(tx?.payload).to.be.equal('ba_AQIDBI3kcuI=');
});

it('Get Account by block height/hash', async () => {
await aeSdk.awaitHeight(await aeSdk.getHeight() + 3);
const spend = await aeSdk.spend(123, 'ak_DMNCzsVoZnpV5fe8FTQnNsTfQ48YM5C3WbHPsJyHjAuTXebFi');
Expand Down
3 changes: 1 addition & 2 deletions test/integration/aens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { getSdk } from '.';
import { assertNotNull, randomName } from '../utils';
import {
AeSdk, generateKeyPair, buildContractId, computeAuctionEndBlock, computeBidFee,
AensPointerContextError, UnexpectedTsError, encode, decode, Encoding,
AensPointerContextError, UnexpectedTsError, encode, decode, Encoding, ContractMethodsBase,
} from '../../src';
import { pause } from '../../src/utils/other';
import { ContractMethodsBase } from '../../src/contract/Contract';

describe('Aens', () => {
let aeSdk: AeSdk;
Expand Down
3 changes: 1 addition & 2 deletions test/integration/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { expect } from 'chai';
import { PipelineRequest, PipelineResponse, SendRequest } from '@azure/core-rest-pipeline';
import { getSdk } from '.';
import {
generateKeyPair, AeSdk, Tag, UnexpectedTsError, MemoryAccount,
generateKeyPair, AeSdk, Tag, UnexpectedTsError, MemoryAccount, Encoded,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';
import { assertNotNull } from '../utils';

describe('Node Chain', () => {
Expand Down
10 changes: 4 additions & 6 deletions test/integration/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { getSdk } from '.';
import {
unpackTx,
buildTxHash,
encode,
decode,
encode, decode, Encoded, Encoding,
Tag,
AbiVersion,
VmVersion,
Expand All @@ -22,13 +21,12 @@ import {
Contract,
Channel,
buildTx,
MemoryAccount,
} from '../../src';
import { pause } from '../../src/utils/other';
import {
ChannelOptions, notify, SignTx, SignTxWithTag,
} from '../../src/channel/internal';
import MemoryAccount from '../../src/account/Memory';
import { Encoded, Encoding } from '../../src/utils/encoder';
import { appendSignature } from '../../src/channel/handlers';
import { assertNotNull, ensureEqual } from '../utils';

Expand Down Expand Up @@ -736,14 +734,14 @@ describe('Channel', () => {
responderCh.disconnect();
initiatorCh = await Channel.initialize({
...sharedParams,
lockPeriod: 5,
lockPeriod: 2,
role: 'initiator',
sign: initiatorSignTag,
port: 3004,
});
responderCh = await Channel.initialize({
...sharedParams,
lockPeriod: 5,
lockPeriod: 2,
role: 'responder',
sign: responderSignTag,
port: 3004,
Expand Down
3 changes: 1 addition & 2 deletions test/integration/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { describe, it } from 'mocha';
import { readFile } from 'fs/promises';
import { compilerUrl, ignoreVersion } from '.';
import {
CompilerBase, CompilerHttpNode, CompilerCli, CompilerError, getFileSystem,
CompilerBase, CompilerHttpNode, CompilerCli, CompilerError, getFileSystem, Encoded,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';

function testCompiler(compiler: CompilerBase): void {
const inclSourceCodePath = './test/integration/contracts/Includes.aes';
Expand Down
29 changes: 22 additions & 7 deletions test/integration/contract-aci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { before, describe, it } from 'mocha';
import BigNumber from 'bignumber.js';
import {
AeSdk,
decode,
decode, Encoded,
BytecodeMismatchError,
InvalidAensNameError,
MissingContractAddressError,
Expand All @@ -12,15 +12,17 @@ import {
MissingEventDefinitionError,
AmbiguousEventDefinitionError,
IllegalArgumentError,
Contract,
Contract, ContractMethodsBase,
hash,
AE_AMOUNT_FORMATS,
Tag,
} from '../../src';
import { getSdk } from '.';
import { Encoded } from '../../src/utils/encoder';
import { assertNotNull, ChainTtl, InputNumber } from '../utils';
import {
assertNotNull, ChainTtl, ensureEqual, InputNumber,
} from '../utils';
import { Aci } from '../../src/contract/compiler/Base';
import { ContractMethodsBase, ContractCallObject } from '../../src/contract/Contract';
import { ContractCallObject } from '../../src/contract/Contract';

const identityContractSourceCode = `
contract Identity =
Expand Down Expand Up @@ -261,7 +263,18 @@ describe('Contract instance', () => {
});

it('calls', async () => {
expect((await testContract.intFn(2)).decodedResult).to.be.equal(2n);
const res = await testContract.intFn(2);
expect(res.decodedResult).to.be.equal(2n);
ensureEqual<Tag.ContractCallTx>(res.tx.tag, Tag.ContractCallTx);
expect(res.tx.fee).to.be.equal('182000000000000');
});

it('calls on chain', async () => {
const res = await testContract.intFn(2, { callStatic: false });
expect(res.decodedResult).to.be.equal(2n);
ensureEqual<Tag.SignedTx>(res.tx.tag, Tag.SignedTx);
ensureEqual<Tag.ContractCallTx>(res.tx.encodedTx.tag, Tag.ContractCallTx);
expect(res.tx.encodedTx.fee).to.be.equal('182000000000000');
});

it('calls without waitMined and get result later', async () => {
Expand Down Expand Up @@ -505,7 +518,9 @@ describe('Contract instance', () => {
});

it('sets maximum possible gas limit for dry-run contract calls', async () => {
const { tx: { gasLimit } } = await contract.intFn(4);
const { tx } = await contract.intFn(4);
ensureEqual<Tag.ContractCallTx>(tx.tag, Tag.ContractCallTx);
const { gasLimit } = tx;
expect(gasLimit).to.be.equal(5817980);
await expect(contract.intFn(4, { gasLimit: gasLimit + 1 }))
.to.be.rejectedWith(IllegalArgumentError, 'Gas limit 5817981 must be less or equal to 5817980');
Expand Down
7 changes: 2 additions & 5 deletions test/integration/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import {
IllegalArgumentError,
NodeInvocationError,
commitmentHash,
decode,
encode,
decode, encode, Encoded, Encoding,
DRY_RUN_ACCOUNT,
messageToHash,
genSalt,
UnexpectedTsError,
AeSdk,
Contract,
Contract, ContractMethodsBase,
} from '../../src';
import { Encoded, Encoding } from '../../src/utils/encoder';
import { ContractMethodsBase } from '../../src/contract/Contract';

const identitySourceCode = `
contract Identity =
Expand Down
3 changes: 1 addition & 2 deletions test/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
AeSdk, CompilerHttpNode, MemoryAccount, Node,
AeSdk, CompilerHttpNode, MemoryAccount, Node, Encoded,
} from '../../src';
import '..';
import { Encoded } from '../../src/utils/encoder';

export const url = process.env.TEST_URL ?? 'http://localhost:3013';
export const compilerUrl = process.env.COMPILER_URL ?? 'http://localhost:3080';
Expand Down
6 changes: 3 additions & 3 deletions test/integration/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { RestError } from '@azure/core-rest-pipeline';
import { getSdk } from '.';
import {
AeSdk, UnexpectedTsError,
decode, encode, registerOracle,
ORACLE_TTL_TYPES, Encoding, RequestTimedOutError,
decode, encode, Encoding, Encoded,
registerOracle,
ORACLE_TTL_TYPES, RequestTimedOutError,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';

describe('Oracle', () => {
let aeSdk: AeSdk;
Expand Down
3 changes: 1 addition & 2 deletions test/integration/paying-for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { expect } from 'chai';
import BigNumber from 'bignumber.js';
import { getSdk } from '.';
import {
AeSdk, Contract, MemoryAccount, Tag, UnexpectedTsError,
AeSdk, Contract, MemoryAccount, Tag, UnexpectedTsError, Encoded,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';
import { InputNumber } from '../utils';

describe('Paying for transaction of another account', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Tag,
WALLET_TYPE,
unpackTx,
decode,
decode, encode, Encoded, Encoding,
MESSAGE_DIRECTION,
METHODS,
RPC_STATUS,
Expand All @@ -38,7 +38,6 @@ import {
getSdk, ignoreVersion, networkId, url, compilerUrl,
} from '.';
import { Accounts, Network } from '../../src/aepp-wallet-communication/rpc/types';
import { encode, Encoded, Encoding } from '../../src/utils/encoder';

const WindowPostMessageFake = (
name: string,
Expand Down
Loading

0 comments on commit 26014b7

Please sign in to comment.