Skip to content

Commit

Permalink
Merge branch 'main' of github.com:paritytech/txwrapper-core into tari…
Browse files Browse the repository at this point in the history
…k-transfer-allow-death
  • Loading branch information
TarikGul committed Jun 29, 2023
2 parents b2790ec + 86d9620 commit 98f9e61
Show file tree
Hide file tree
Showing 29 changed files with 674 additions and 338 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.0.1](https://github.com/paritytech/txwrapper-core/compare/v6.0.0...v6.0.1) (2023-05-25)


### Bug Fixes

* safer process.env access ([#301](https://github.com/paritytech/txwrapper-core/issues/301)) ([0035d23](https://github.com/paritytech/txwrapper-core/commit/0035d236db34b33ced4a419c710890b566628980))





# [6.0.0](https://github.com/paritytech/txwrapper-core/compare/v5.0.1...v6.0.0) (2023-05-08)


### Bug Fixes

* add detectOpenHandles flag in tests (jest) ([#285](https://github.com/paritytech/txwrapper-core/issues/285)) ([90a231e](https://github.com/paritytech/txwrapper-core/commit/90a231e07e69de96602f92d37897493ac2e7b7f7))
* adjust memoization and cache ([#298](https://github.com/paritytech/txwrapper-core/issues/298)) ([a0ae8c7](https://github.com/paritytech/txwrapper-core/commit/a0ae8c72570910598ef6787228a559c11196d001))
* rework `deriveAddress` to have all schemes support ([#293](https://github.com/paritytech/txwrapper-core/issues/293)) ([5b99d23](https://github.com/paritytech/txwrapper-core/commit/5b99d2396a078186145377e11beb2faf1c4e7815))


* fix!: refactor the whole testing system with metadata, remove old calls, and fix some types (#295) ([58d026a](https://github.com/paritytech/txwrapper-core/commit/58d026ad7c0d9eaa0816fddf33735d4015e22edd)), closes [#295](https://github.com/paritytech/txwrapper-core/issues/295)


### Features

* add `additionalTypes`, and `typesBundle` to `getRegistryBase` ([#294](https://github.com/paritytech/txwrapper-core/issues/294)) ([671a2d1](https://github.com/paritytech/txwrapper-core/commit/671a2d168a114866455aff2f01d0d019eeeed2d3))


### BREAKING CHANGES

* fix balances

* metadata and decode

* method

* remove constants

* remove a large amount of bloat

* ensure setKets kets type is correct





## [5.0.1](https://github.com/paritytech/txwrapper-core/compare/v5.0.0...v5.0.1) (2023-02-28)

**Note:** Version bump only for package txwrapper-core
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For example, those looking to construct a transaction offline on Polkadot would

#### Non-published

- [@substrate/txwrapper-dev](/packages/txwrapper-dev/README.md) Exported development helpers such as registries and metadata.
- [@substrate/txwrapper-example](/packages/txwrapper-examples/README.md) Usage examples including how to construct, sign, and decode an extrinsic with @substrate/txwrapper-polkadot.
- [@substrate/txwrapper-template](/packages/txwrapper-template/README.md) Template package for chain builders.

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "5.0.1",
"version": "6.0.1",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"docs": "typedoc --gitRemote origin"
},
"devDependencies": {
"@polkadot/util-crypto": "^11.1.2",
"@polkadot/util-crypto": "^12.2.1",
"@substrate/dev": "^0.6.7",
"@types/node-fetch": "^2.6.3",
"lerna": "^4.0.0",
Expand Down
46 changes: 46 additions & 0 deletions packages/txwrapper-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,52 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.0.1](https://github.com/paritytech/txwrapper-core/compare/v6.0.0...v6.0.1) (2023-05-25)


### Bug Fixes

* safer process.env access ([#301](https://github.com/paritytech/txwrapper-core/issues/301)) ([0035d23](https://github.com/paritytech/txwrapper-core/commit/0035d236db34b33ced4a419c710890b566628980))





# [6.0.0](https://github.com/paritytech/txwrapper-core/compare/v5.0.1...v6.0.0) (2023-05-08)


### Bug Fixes

* adjust memoization and cache ([#298](https://github.com/paritytech/txwrapper-core/issues/298)) ([a0ae8c7](https://github.com/paritytech/txwrapper-core/commit/a0ae8c72570910598ef6787228a559c11196d001))
* rework `deriveAddress` to have all schemes support ([#293](https://github.com/paritytech/txwrapper-core/issues/293)) ([5b99d23](https://github.com/paritytech/txwrapper-core/commit/5b99d2396a078186145377e11beb2faf1c4e7815))


* fix!: refactor the whole testing system with metadata, remove old calls, and fix some types (#295) ([58d026a](https://github.com/paritytech/txwrapper-core/commit/58d026ad7c0d9eaa0816fddf33735d4015e22edd)), closes [#295](https://github.com/paritytech/txwrapper-core/issues/295)


### Features

* add `additionalTypes`, and `typesBundle` to `getRegistryBase` ([#294](https://github.com/paritytech/txwrapper-core/issues/294)) ([671a2d1](https://github.com/paritytech/txwrapper-core/commit/671a2d168a114866455aff2f01d0d019eeeed2d3))


### BREAKING CHANGES

* fix balances

* metadata and decode

* method

* remove constants

* remove a large amount of bloat

* ensure setKets kets type is correct





## [5.0.1](https://github.com/paritytech/txwrapper-core/compare/v5.0.0...v5.0.1) (2023-02-28)

**Note:** Version bump only for package @substrate/txwrapper-core
Expand Down
42 changes: 33 additions & 9 deletions packages/txwrapper-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,39 @@
yarn add @substrate/txwrapper-core
```

In a JS/TS index file of package:
Have a look at the [txwrapper creation guide for chain builders](../../CHAIN_BUILDER.md) to see more guidance on how to use this package to build a chain specific txwrapper.

```typescript
import { methods as ORMLMethods } from '@substrate/txwrapper-orml';
## Env Variables

// Export methods of pallets included in the chain's runtime.
export const methods = {
currencies: ORMLMethods.currencies,
};
```
This is a list of env variables that are used inside of txwrapper-core.

Have a look at the [txwrapper creation guide for chain builders](../../CHAIN_BUILDER.md) to see more guidance on how to use this package to build a chain specific txwrapper.

### `createMetadata` specific env vars.

**Summary**:
`createMetadata` memoizes the call to ensure metadata is not reallocated in memory if it is the same call.

Methods that actively use `createMetadata` and are affected are:
- `defineMethod`
- `createDecoratedTx`
- `createDecoratedConstants`
- `createSignedTx`
- `decodeSignedTx`
- `decodeSigningPayload`
- `decodeUnsignedTx`

NOTE: `getRegistryBase` uses `createMetadataUnmemoized`

#### `TXWRAPPER_METADATA_CACHE_MAX`

**Summary**:
Set the max amount of memoized calls we want in the cache. It uses an LRU cache to handle the input and output of values. This takes in an integer. Ex: `export TXWRAPPER_METADATA_CACHE_MAX=10`. This will default to unlimited size if the value is not inputted.

NOTES:

- It is recommended to use a value greater 2 for the cache size as regressions have been seen in some cases for 2 or lower.

#### `TXWRAPPER_METADATA_CACHE_MAX`

**Summary**:
Set the TTL (Time To Live) for items in the memoized cache. This takes in an integer in the measurement of milliseconds. Ex: `export TXWRAPPER_METADATA_CACHE_MAX=1000` for 1 second.
8 changes: 4 additions & 4 deletions packages/txwrapper-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@substrate/txwrapper-core",
"version": "5.0.1",
"version": "6.0.1",
"author": "Parity Technologies <admin@parity.io>",
"description": "Core components for creating a txwrapper lib.",
"license": "Apache-2.0",
Expand All @@ -18,12 +18,12 @@
"build": "yarn build:workspace"
},
"dependencies": {
"@polkadot/api": "^10.2.1",
"@polkadot/keyring": "^11.1.2",
"@polkadot/api": "^10.7.1",
"@polkadot/keyring": "^12.2.1",
"memoizee": "0.4.15"
},
"devDependencies": {
"@substrate/txwrapper-dev": "^5.0.0",
"@substrate/txwrapper-dev": "^6.0.0",
"@types/memoizee": "^0.4.3"
}
}
13 changes: 12 additions & 1 deletion packages/txwrapper-core/src/core/metadata/createMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TypeRegistry } from '@polkadot/types';
import { MetadataVersioned } from '@polkadot/types/metadata/MetadataVersioned';
import memoizee from 'memoizee';

import { isBrowser } from '../util';
import { toSpecifiedCallsOnlyV14 } from './toSpecifiedCallsOnlyV14';

/**
Expand Down Expand Up @@ -51,5 +52,15 @@ export function createMetadataUnmemoized(
* @param asCallsOnlyArg - Option to decreases the metadata to calls only
*/
export const createMetadata = memoizee(createMetadataUnmemoized, {
length: 3,
length: 4,
max:
!isBrowser &&
typeof process?.env?.TXWRAPPER_METADATA_CACHE_MAX !== 'undefined'
? parseInt(process.env.TXWRAPPER_METADATA_CACHE_MAX)
: undefined,
maxAge:
!isBrowser &&
typeof process?.env?.TXWRAPPER_METADATA_CACHE_MAX_AGE !== 'undefined'
? parseInt(process.env.TXWRAPPER_METADATA_CACHE_MAX_AGE)
: undefined,
});
5 changes: 2 additions & 3 deletions packages/txwrapper-core/src/core/metadata/getRegistryBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@polkadot/types/types';

import { ChainProperties } from '../../types';
import { createMetadata } from './createMetadata';
import { createMetadataUnmemoized } from './createMetadata';

export interface GetRegistryBaseArgs {
/**
Expand Down Expand Up @@ -58,8 +58,7 @@ export function getRegistryBase({
additionalTypes,
}: GetRegistryBaseArgs): TypeRegistry {
const registry = new TypeRegistry();

const generatedMetadata = createMetadata(
const generatedMetadata = createMetadataUnmemoized(
registry,
metadataRpc,
asCallsOnlyArg
Expand Down
1 change: 1 addition & 0 deletions packages/txwrapper-core/src/core/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './deriveAddress';
export * from './importPrivateKey';
export * from './isBrowser';
export * from './polkadotss58Format';
1 change: 1 addition & 0 deletions packages/txwrapper-core/src/core/util/isBrowser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isBrowser = typeof window !== 'undefined';
Original file line number Diff line number Diff line change
Expand Up @@ -36778,6 +36778,7 @@
},
"events": null,
"constants": [],
"docs": [],
"errors": null,
"index": 0
},
Expand All @@ -36789,10 +36790,12 @@
},
"events": null,
"constants": [],
"docs": [],
"errors": null,
"index": 4
}
],
"apis": [],
"extrinsic": {
"type": 857,
"version": 4,
Expand Down
29 changes: 29 additions & 0 deletions packages/txwrapper-dev/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,35 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.0.0](https://github.com/paritytech/txwrapper-core/compare/v5.0.1...v6.0.0) (2023-05-08)


* fix!: refactor the whole testing system with metadata, remove old calls, and fix some types (#295) ([58d026a](https://github.com/paritytech/txwrapper-core/commit/58d026ad7c0d9eaa0816fddf33735d4015e22edd)), closes [#295](https://github.com/paritytech/txwrapper-core/issues/295)


### Features

* add `additionalTypes`, and `typesBundle` to `getRegistryBase` ([#294](https://github.com/paritytech/txwrapper-core/issues/294)) ([671a2d1](https://github.com/paritytech/txwrapper-core/commit/671a2d168a114866455aff2f01d0d019eeeed2d3))


### BREAKING CHANGES

* fix balances

* metadata and decode

* method

* remove constants

* remove a large amount of bloat

* ensure setKets kets type is correct





# [5.0.0](https://github.com/paritytech/txwrapper-core/compare/v4.1.0...v5.0.0) (2023-01-13)


Expand Down
2 changes: 1 addition & 1 deletion packages/txwrapper-dev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@substrate/txwrapper-dev",
"version": "5.0.0",
"version": "6.0.0",
"author": "Parity Technologies <admin@parity.io>",
"description": "Core components for creating a txwrapper lib.",
"license": "Apache-2.0",
Expand Down
32 changes: 32 additions & 0 deletions packages/txwrapper-examples/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.0.1](https://github.com/paritytech/txwrapper-core/compare/v6.0.0...v6.0.1) (2023-05-25)

**Note:** Version bump only for package @substrate/txwrapper-examples





# [6.0.0](https://github.com/paritytech/txwrapper-core/compare/v5.0.1...v6.0.0) (2023-05-08)


* fix!: refactor the whole testing system with metadata, remove old calls, and fix some types (#295) ([58d026a](https://github.com/paritytech/txwrapper-core/commit/58d026ad7c0d9eaa0816fddf33735d4015e22edd)), closes [#295](https://github.com/paritytech/txwrapper-core/issues/295)


### BREAKING CHANGES

* fix balances

* metadata and decode

* method

* remove constants

* remove a large amount of bloat

* ensure setKets kets type is correct





## [5.0.1](https://github.com/paritytech/txwrapper-core/compare/v5.0.0...v5.0.1) (2023-02-28)

**Note:** Version bump only for package @substrate/txwrapper-examples
Expand Down
8 changes: 4 additions & 4 deletions packages/txwrapper-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@substrate/txwrapper-examples",
"version": "5.0.1",
"version": "6.0.1",
"author": "Parity Technologies <admin@parity.io>",
"description": "Examples for txwrapper-* usage.",
"license": "Apache-2.0",
Expand All @@ -22,8 +22,8 @@
"asSpecifiedCallsOnlyV14": "node lib/options/src/asSpecifiedCallsOnlyV14"
},
"dependencies": {
"@polkadot/api": "^10.2.1",
"@substrate/txwrapper-polkadot": "^5.0.1",
"@substrate/txwrapper-registry": "^5.0.1"
"@polkadot/api": "^10.7.1",
"@substrate/txwrapper-polkadot": "^6.0.1",
"@substrate/txwrapper-registry": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/txwrapper-examples/polkadot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Here's a mini-tutorial on how `txwrapper-polkadot` can interact with a Polkadot
1) Fetch the latest Substrate or Polkadot/Kusama node from the above link. Follow the instructions to build it, and start a dev chain.

```bash
target/release/polkadot --dev
target/release/polkadot --dev --rpc-port 9933
```

2) Install dependencies and build the JS target
Expand Down
Loading

0 comments on commit 98f9e61

Please sign in to comment.