Skip to content

Commit

Permalink
fix: rename state{mint, mine} to asset-hub-* (#307)
Browse files Browse the repository at this point in the history
* fix: rename state{mint, mine} to asset-hub-*

* Update txwrapper-polkadot

* lint

---------

Co-authored-by: tarikgul <tarik@parity.io>
  • Loading branch information
Imod7 and TarikGul authored Jul 4, 2023
1 parent 6a72939 commit 3a1822a
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 59 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For example, those looking to construct a transaction offline on Polkadot would

#### Published

- [@substrate/txwrapper-polkadot](/packages/txwrapper-polkadot/README.md) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Statemint and Statemine.
- [@substrate/txwrapper-polkadot](/packages/txwrapper-polkadot/README.md) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Asset Hub Polkadot and Asset Hub Kusama.
- [@substrate/txwrapper-core](/packages/txwrapper-core/README.md) The essentials for creating a chain specific txwrapper lib.
- [@substrate/txwrapper-registry](/packages/txwrapper-registry/README.md) Registry creation support, catering to chains with types in [@polkadot/apps-config](https://github.com/polkadot-js/apps/tree/master/packages/apps-config/README.md).
- [@substrate/txwrapper-substrate](/packages/txwrapper-substrate/README.md) Selected dispatchables of Substrate pallets, to be re-exported by txwrappers (e.g. @substrate/txwrapper-polkadot).
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For example, those looking to construct a transaction offline on Polkadot would

#### Published

- [@substrate/txwrapper-polkadot](/packages/txwrapper-polkadot/README.md) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Statemint and Statemine.
- [@substrate/txwrapper-polkadot](/packages/txwrapper-polkadot/README.md) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Asset Hub Polkadot and Asset Hub Kusama.
- [@substrate/txwrapper-core](/packages/txwrapper-core/README.md) The essentials for creating a chain specific txwrapper lib.
- [@substrate/txwrapper-registry](/packages/txwrapper-registry/README.md) Registry creation support, catering to chains with types in [@polkadot/apps-config](https://github.com/polkadot-js/apps/tree/master/packages/apps-config/README.md).
- [@substrate/txwrapper-substrate](/packages/txwrapper-substrate/README.md) Selected dispatchables of Substrate pallets, to be re-exported by txwrappers (e.g. @substrate/txwrapper-polkadot).
Expand Down
20 changes: 10 additions & 10 deletions packages/txwrapper-dev/src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { assetHubKusamaMetadataHex } from '../metadata/asset-hub-kusama';
import { kusamaMetadataHex } from '../metadata/kusama';
import { polkadotMetadataHex } from '../metadata/polkadot';
import { statemineMetadataHex } from '../metadata/statemine';
import { westendMetadataHex } from '../metadata/westend';
import {
memoizedAssetHubKusamaGetRegistry,
memoizedKusamaGetRegistry,
memoizedPolkadotGetRegistry,
memoizedStatemineGetRegistry,
memoizedWestendGetRegistry,
} from '../registries';

export const KUSAMA_SPEC_VERSION = 9430;
export const POLKADOT_SPEC_VERSION = 9430;
const STATEMINT_SPEC_VERSION = 9360;
const ASSET_HUB_POLKADOT_SPEC_VERSION = 9360;
const WESTEND_SPEC_VERSION = 9430;

/**
Expand All @@ -32,7 +32,7 @@ export const TEST_BASE_TX_INFO = {
transactionVersion: 6,
};

export const STATEMINT_TEST_BASE_TX_INFO = {
export const ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO = {
address: 'HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F', // seed "//Alice"
blockHash:
'0x1fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582',
Expand All @@ -42,7 +42,7 @@ export const STATEMINT_TEST_BASE_TX_INFO = {
'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636',
metadataRpc: kusamaMetadataHex,
nonce: 2,
specVersion: STATEMINT_SPEC_VERSION,
specVersion: ASSET_HUB_POLKADOT_SPEC_VERSION,
tip: 0,
transactionVersion: 6,
};
Expand Down Expand Up @@ -96,11 +96,11 @@ export const KUSAMA_TEST_OPTIONS_CALLS_ONLY = {
asCallsOnlyArg: true,
};

export const STATEMINE_TEST_OPTIONS = {
metadataRpc: statemineMetadataHex,
registry: memoizedStatemineGetRegistry(
STATEMINT_SPEC_VERSION,
statemineMetadataHex
export const ASSET_HUB_KUSAMA_TEST_OPTIONS = {
metadataRpc: assetHubKusamaMetadataHex,
registry: memoizedAssetHubKusamaGetRegistry(
ASSET_HUB_POLKADOT_SPEC_VERSION,
assetHubKusamaMetadataHex
),
};

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './assetHubKusamaMetadataHex';
1 change: 0 additions & 1 deletion packages/txwrapper-dev/src/metadata/statemine/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mockGetRegistryBase } from './mockGetRegistry';
* @param specVersion
* @param metadataRpc
*/
export function getRegistryStatemine(
export function getRegistryAssetHubKusama(
specVersion: number,
metadataRpc: `0x${string}`
): TypeRegistry {
Expand All @@ -22,12 +22,14 @@ export function getRegistryStatemine(
},
specTypes: getSpecTypes(
new TypeRegistry(),
'Statemine',
'Asset Hub Kusama',
'statemine',
specVersion
),
metadataRpc,
});
}

export const memoizedStatemineGetRegistry = memoizee(getRegistryStatemine);
export const memoizedAssetHubKusamaGetRegistry = memoizee(
getRegistryAssetHubKusama
);
2 changes: 1 addition & 1 deletion packages/txwrapper-dev/src/registries/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './assetHubKusamaRegistry';
export * from './kusamaRegistry';
export * from './polkadotRegistry';
export * from './statemineRegistry';
export * from './westendRegistry';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Statemint/Statemine Sufficient Asset Example:
# Asset Hub Polkadot/Asset Hub Kusama Sufficient Asset Example:

Note: this example uses the substrate chain `trappist-rococo` which serves as a wrapper for a statemint/statemine environment
Note: this example uses the substrate chain `trappist-rococo` which serves as a wrapper for a Asset Hub Polkadot/Asset Hub Kusama environment

## How to construct a transaction using a sufficient asset to pay fees in `txwrapper-core`

Expand Down Expand Up @@ -81,14 +81,14 @@ Note for this step: If an `orange` icon appears in the top right after submittin
11) In `txwrapper-core/packages/txwrapper-examples/common/util.ts`, update the http port in the `rpcToLocalNode` function to your `trappist-collator1` node's ws port + 1(e.g. given a `trappist-local` ws port of `54600`, update txwrapper-cores http port to `54601`)
12) In `txwrapper-core/packages/txwrapper-examples/statemint/src/statemint.ts`, update the `assetId` in the `transferKeepAlive` function to the asset id you provided for your test asset.
12) In `txwrapper-core/packages/txwrapper-examples/assetHubPolkadot/src/assetHubPolkadot.ts`, update the `assetId` in the `transferKeepAlive` function to the asset id you provided for your test asset.
13) After upodating the http port in the previous step and adding the correct `assetId` to the `transferKeepAlive` function in `statemint.ts`, run the example script in the `txwrapper-examples` package (see [txwrapper-core/packages/txwrapper-examples/statemint/src/statemint.ts](txwrapper-core/packages/txwrapper-examples/statemint/src/statemint.ts)). It will interact with your local node.
13) After updating the http port in the previous step and adding the correct `assetId` to the `transferKeepAlive` function in `assetHubPolkadot.ts`, run the example script in the `txwrapper-examples` package (see [txwrapper-core/packages/txwrapper-examples/assetHubPolkadot/src/assetHubPolkadot.ts](txwrapper-core/packages/txwrapper-examples/assetHubPolkadot/src/assetHubPolkadot.ts)). It will interact with your local node.
From the root of `txwrapper-examples`
```bash
yarn run statemint
yarn run assetHubPolkadot
```
## Example Output
Expand Down
2 changes: 1 addition & 1 deletion packages/txwrapper-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build": "yarn build:workspace",
"polkadot": "node lib/polkadot/src/polkadot",
"statemint": "node lib/statemint/src/statemint",
"assetHubPolkadot": "node lib/assetHubPolkadot/src/assetHubPolkadot",
"polkadotBatchAll": "node lib/polkadotBatchAll/src/polkadotBatchAll",
"mandala": "node lib/mandala",
"multisig": "node lib/multisig/src/multisig",
Expand Down
2 changes: 1 addition & 1 deletion packages/txwrapper-polkadot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# About

Txwrapper library for polkadot relay and system chains; specifically Polkadot, Kusama, Rococo, Westend, Statemint and Statemine.
Txwrapper library for polkadot relay and system chains; specifically Polkadot, Kusama, Rococo, Westend, Asset Hub Polkadot and Asset Hub Kusama.

Note: not all methods available apply to all supported chains. To check what methods are supported by a chain consult the pallets included in chain's runtime.

Expand Down
39 changes: 26 additions & 13 deletions packages/txwrapper-polkadot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { methods as substrateMethods } from '@substrate/txwrapper-substrate';

import * as polkadotMethods from './methods';

// Export methods of pallets included in the Polkadot, Kusama, Westend, Rococo
// and State{mint, mine} runtimes.
// Export methods of pallets included in the Polkadot, Kusama, Westend, Rococo,
// Asset Hub Polkadot and Asset Hub Kusama runtimes.
// Note: in the future this may also include methods defined within this package
// that do not exist in Substrate.
export const methods = {
Expand All @@ -24,7 +24,7 @@ export const methods = {
vesting: substrateMethods.vesting,
multisig: substrateMethods.multisig,
crowdloan: polkadotMethods.crowdloan,
// assets is only applicable to State{mint, mine}
// assets is only applicable to Asset Hub Polkadot and Asset Hub Kusama
assets: substrateMethods.assets,
};

Expand Down Expand Up @@ -52,6 +52,8 @@ const KNOWN_CHAIN_PROPERTIES = {
tokenDecimals: 12,
tokenSymbol: 'WND',
},
// Even though we are transitioning to `asset-hub-*`, we will keep
// statemint, statemine, and westmint for a smooth transition.
statemint: {
ss58Format: PolkadotSS58Format.polkadot,
tokenDecimals: 10,
Expand All @@ -62,6 +64,26 @@ const KNOWN_CHAIN_PROPERTIES = {
tokenDecimals: 12,
tokenSymbol: 'KSM',
},
westmint: {
ss58Format: PolkadotSS58Format.westend,
tokenDecimals: 12,
tokenSymbol: 'WND',
},
'asset-hub-kusama': {
ss58Format: PolkadotSS58Format.kusama,
tokenDecimals: 12,
tokenSymbol: 'KSM',
},
'asset-hub-polkadot': {
ss58Format: PolkadotSS58Format.polkadot,
tokenDecimals: 10,
tokenSymbol: 'DOT',
},
'asset-hub-westend': {
ss58Format: PolkadotSS58Format.westend,
tokenDecimals: 12,
tokenSymbol: 'WND',
},
};

// We override the `specName` property of `GetRegistryOptsCore` in order to get narrower type specificity,
Expand Down Expand Up @@ -93,18 +115,9 @@ export function getRegistry({
// The default type registry has polkadot types
const registry = new TypeRegistry();

// As of now statemine is not a supported specName in the default polkadot-js/api type registry.
const chainNameAdjusted = chainName === 'Statemine' ? 'Statemint' : chainName;
const specNameAdjusted = specName === 'statemine' ? 'statemint' : specName;

return getRegistryBase({
chainProperties: properties || KNOWN_CHAIN_PROPERTIES[specName],
specTypes: getSpecTypes(
registry,
chainNameAdjusted,
specNameAdjusted,
specVersion
),
specTypes: getSpecTypes(registry, chainName, specName, specVersion),
metadataRpc,
asCallsOnlyArg,
signedExtensions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ASSET_HUB_KUSAMA_TEST_OPTIONS,
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
itHasCorrectBaseTxInfo,
STATEMINE_TEST_OPTIONS,
STATEMINT_TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
Expand All @@ -11,8 +11,8 @@ describe('assets:approveTransfer', () => {
it('should work', () => {
const unsigned = approveTransfer(
TEST_METHOD_ARGS.assets.approveTransfer,
STATEMINT_TEST_BASE_TX_INFO,
STATEMINE_TEST_OPTIONS
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
ASSET_HUB_KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ASSET_HUB_KUSAMA_TEST_OPTIONS,
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
itHasCorrectBaseTxInfo,
STATEMINE_TEST_OPTIONS,
STATEMINT_TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
Expand All @@ -11,8 +11,8 @@ describe('assets:cancelApproval', () => {
it('should work', () => {
const unsigned = cancelApproval(
TEST_METHOD_ARGS.assets.cancelApproval,
STATEMINT_TEST_BASE_TX_INFO,
STATEMINE_TEST_OPTIONS
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
ASSET_HUB_KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ASSET_HUB_KUSAMA_TEST_OPTIONS,
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
itHasCorrectBaseTxInfo,
STATEMINE_TEST_OPTIONS,
STATEMINT_TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
Expand All @@ -11,8 +11,8 @@ describe('assets:transfer', () => {
it('should work', () => {
const unsigned = transfer(
TEST_METHOD_ARGS.assets.transfer,
STATEMINT_TEST_BASE_TX_INFO,
STATEMINE_TEST_OPTIONS
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
ASSET_HUB_KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ASSET_HUB_KUSAMA_TEST_OPTIONS,
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
itHasCorrectBaseTxInfo,
STATEMINE_TEST_OPTIONS,
STATEMINT_TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
Expand All @@ -11,8 +11,8 @@ describe('assets:cancelApproval', () => {
it('should work', () => {
const unsigned = transferApproved(
TEST_METHOD_ARGS.assets.transferApproved,
STATEMINT_TEST_BASE_TX_INFO,
STATEMINE_TEST_OPTIONS
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
ASSET_HUB_KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ASSET_HUB_KUSAMA_TEST_OPTIONS,
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
itHasCorrectBaseTxInfo,
STATEMINE_TEST_OPTIONS,
STATEMINT_TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
Expand All @@ -11,8 +11,8 @@ describe('assets:transferKeepAlive', () => {
it('should work', () => {
const unsigned = transferKeepAlive(
TEST_METHOD_ARGS.assets.transferKeepAlive,
STATEMINT_TEST_BASE_TX_INFO,
STATEMINE_TEST_OPTIONS
ASSET_HUB_POLKADOT_TEST_BASE_TX_INFO,
ASSET_HUB_KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);
Expand Down

0 comments on commit 3a1822a

Please sign in to comment.