Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename state{mint, mine} to asset-hub-* #307

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,12 +1,12 @@
import { assetHubKusamaMetadataHex } from '../metadata/asset-hub-kusama';
import { kusamaMetadataHex } from '../metadata/kusama';
import { statemineMetadataHex } from '../metadata/statemine';
import {
memoizedAssetHubKusamaGetRegistry,
memoizedKusamaGetRegistry,
memoizedStatemineGetRegistry,
} from '../registries';

export const KUSAMA_SPEC_VERSION = 9390;
const STATEMINT_SPEC_VERSION = 9360;
const ASSET_HUB_POLKADOT_SPEC_VERSION = 9360;

/**
* Base tx information common to all tested transactions
Expand All @@ -26,7 +26,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 @@ -36,7 +36,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 All @@ -52,11 +52,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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO things like this make the transition confusing because this is actually not Asset hub Kusama since the metadata passed in does not recognize asset-hub yet. Which means we would need to do 2 PR's that properly change over everything. We should really keep this to what is defined in the metadata, and hold off on having 2 different names here.

My question here would be does getSpecTypes recognize 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,2 +1,2 @@
export * from './assetHubKusamaRegistry';
export * from './kusamaRegistry';
export * from './statemineRegistry';
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
9 changes: 5 additions & 4 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 @@ -94,7 +94,8 @@ export function getRegistry({
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 chainNameAdjusted =
TarikGul marked this conversation as resolved.
Show resolved Hide resolved
chainName === 'Asset Hub Kusama' ? 'Asset Hub Polkadot' : chainName;
const specNameAdjusted = specName === 'statemine' ? 'statemint' : specName;

return getRegistryBase({
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