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(deps): bumped @substrate/dev to v0.7.1 #357

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
},
"devDependencies": {
"@polkadot/util-crypto": "^12.6.2",
"@substrate/dev": "^0.6.7",
"@substrate/dev": "^0.7.1",
"@types/node-fetch": "^2.6.3",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"lerna": "^8.1.2",
"rimraf": "3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typedoc": "^0.22.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ describe('createSignedTx', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signingPayload = createSigningPayload(unsigned, KUSAMA_TEST_OPTIONS);
const signature = await signWithAlice(signingPayload);

const tx = createSignedTx(unsigned, signature, KUSAMA_TEST_OPTIONS);
expect(tx).toBe(
'0x2d028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d005b4cf1d210c93eb6e6428a88c1b298e280d761fe50fe02d6c3253075ed23f239bcbc9a4f9bf0494a869f797355daf55ed6de373572328a1f6f4519f48f8f280feb58080004070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30'
'0x2d028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d005b4cf1d210c93eb6e6428a88c1b298e280d761fe50fe02d6c3253075ed23f239bcbc9a4f9bf0494a869f797355daf55ed6de373572328a1f6f4519f48f8f280feb58080004070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30',
);
});

it('should work for Astar', async () => {
const unsigned = balancesTransfer(
ASTAR_TEST_METHOD_ARGS.balances.transfer,
ASTAR_TEST_BASE_TX_INFO,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);
const signingPayload = createSigningPayload(unsigned, ASTAR_TEST_OPTIONS);
const signature = await signWithAlice(signingPayload);

const tx = createSignedTx(unsigned, signature, ASTAR_TEST_OPTIONS);
expect(tx).toBe(
'0x4902840046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22000fff4ac96df07f429c5be356f536a794b4892ec2d5fb516e04f559b0f2548be2ce48fc01501353d244aff9b660fd086c9d1681ba47fade8194c2a4c62d6c5b50adb2a080f0000c52ebca2b11f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030'
'0x4902840046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22000fff4ac96df07f429c5be356f536a794b4892ec2d5fb516e04f559b0f2548be2ce48fc01501353d244aff9b660fd086c9d1681ba47fade8194c2a4c62d6c5b50adb2a080f0000c52ebca2b11f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createMetadata } from '..';
export function createSignedTx(
unsigned: UnsignedTransaction,
signature: `0x${string}`,
options: OptionsWithMeta
options: OptionsWithMeta,
): string {
const {
metadataRpc,
Expand All @@ -28,15 +28,15 @@ export function createSignedTx(
registry,
metadataRpc,
asCallsOnlyArg,
asSpecifiedCallsOnlyV14
asSpecifiedCallsOnlyV14,
);

registry.setMetadata(metadata, signedExtensions, userExtensions);

const extrinsic = registry.createType(
'Extrinsic',
{ method: unsigned.method },
{ version: unsigned.version }
{ version: unsigned.version },
);

extrinsic.addSignature(unsigned.address, signature, unsigned);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe('createSigningPayload', () => {
balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
),
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

expect(signingPayload).toEqual(
'0x9004070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30eb580800d624000006000000e3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f6361fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582'
'0x9004070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30eb580800d624000006000000e3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f6361fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582',
);
});

Expand All @@ -31,13 +31,13 @@ describe('createSigningPayload', () => {
balancesTransfer(
ASTAR_TEST_METHOD_ARGS.balances.transfer,
ASTAR_TEST_BASE_TX_INFO,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
),
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);

expect(signingPayload).toEqual(
'0x901f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030db2a080f0000c52ebca2b148000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c66c8453305b978e867b2ccacea94e01a4ea49dfd6eb0965b6c0ccf36b295e16b5'
'0x901f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030db2a080f0000c52ebca2b148000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c66c8453305b978e867b2ccacea94e01a4ea49dfd6eb0965b6c0ccf36b295e16b5',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { Options, UnsignedTransaction } from '../../types';
*/
export function createSigningPayload(
unsigned: UnsignedTransaction,
options: Options
options: Options,
): string {
const { registry } = options;

Expand All @@ -61,7 +61,7 @@ export function createSigningPayload(
!unsigned.signedExtensions.includes('ChargeAssetTxPayment')
) {
throw new Error(
'invalid transaction argument: assetId. Unsupported signed extension ChargeAssetTxPayment'
'invalid transaction argument: assetId. Unsupported signed extension ChargeAssetTxPayment',
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ describe('createSigningPayloadToU8a', () => {
balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
),
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

expect(u8aToHex(signingPayload)).toEqual(
'0x04070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30eb580800d624000006000000e3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f6361fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582'
'0x04070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30eb580800d624000006000000e3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f6361fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582',
);
});

Expand All @@ -32,13 +32,13 @@ describe('createSigningPayloadToU8a', () => {
balancesTransfer(
ASTAR_TEST_METHOD_ARGS.balances.transfer,
ASTAR_TEST_BASE_TX_INFO,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
),
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);

expect(u8aToHex(signingPayload)).toEqual(
'0x1f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030db2a080f0000c52ebca2b148000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c66c8453305b978e867b2ccacea94e01a4ea49dfd6eb0965b6c0ccf36b295e16b5'
'0x1f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030db2a080f0000c52ebca2b148000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c66c8453305b978e867b2ccacea94e01a4ea49dfd6eb0965b6c0ccf36b295e16b5',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Options, UnsignedTransaction } from '../../types';
*/
export function createSigningPayloadToU8a(
unsigned: UnsignedTransaction,
options: Options
options: Options,
): Uint8Array {
const { registry } = options;
const extrinsicPayload = registry.createType('ExtrinsicPayload', unsigned, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ describe('encodeUnsignedTransaction', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

const encoded = encodeUnsignedTransaction(unsigned, KUSAMA_TEST_OPTIONS);

expect(encoded).toBe(
'0x940404070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30'
'0x940404070096074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d30',
);
});

it('should return the correct output for Astar', () => {
const unsigned = balancesTransfer(
ASTAR_TEST_METHOD_ARGS.balances.transfer,
ASTAR_TEST_BASE_TX_INFO,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);

const encoded = encodeUnsignedTransaction(unsigned, ASTAR_TEST_OPTIONS);

expect(encoded).toBe(
'0x94041f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030'
'0x94041f070046ef637afac0ffa9ec7a7cf76c5e0148200a401e2a1efcf2c16ee1554b74a22030',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { Options, UnsignedTransaction } from '../../types';
*/
export function encodeUnsignedTransaction(
unsigned: UnsignedTransaction,
options: Options
options: Options,
): string {
const tx = options.registry.createType(
'Extrinsic',
{ method: unsigned.method },
{ version: unsigned.version }
{ version: unsigned.version },
);
return tx.toHex();
}
16 changes: 8 additions & 8 deletions packages/txwrapper-core/src/core/construct/getTxHash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,45 @@ describe('getTxHash', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signingPayload = construct.signingPayload(
unsigned,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signature = await signWithAlice(signingPayload);
const signedTx = construct.signedTx(
unsigned,
signature,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

const txHash = getTxHash(signedTx);
expect(txHash).toBe(
'0x50cbe175485736a5284a5758e29608d4e3f95c329ca42b108f7445f9f2ed06bb'
'0x50cbe175485736a5284a5758e29608d4e3f95c329ca42b108f7445f9f2ed06bb',
);
});

it('should work for Astar', async () => {
const unsigned = balancesTransfer(
ASTAR_TEST_METHOD_ARGS.balances.transfer,
ASTAR_TEST_BASE_TX_INFO,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);
const signingPayload = construct.signingPayload(
unsigned,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);
const signature = await signWithAlice(signingPayload);
const signedTx = construct.signedTx(
unsigned,
signature,
ASTAR_TEST_OPTIONS
ASTAR_TEST_OPTIONS,
);

const txHash = getTxHash(signedTx);
expect(txHash).toBe(
'0x1fc108525d6569889d53cbc092cba9c7ad0f59d668c60eff3447c774815d0485'
'0x1fc108525d6569889d53cbc092cba9c7ad0f59d668c60eff3447c774815d0485',
);
});
});
14 changes: 7 additions & 7 deletions packages/txwrapper-core/src/core/decode/decode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ describe('decode', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signingPayload = construct.signingPayload(
unsigned,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signature = await signWithAlice(signingPayload);
const signedTx = construct.signedTx(
unsigned,
signature,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

const decoded = decode(signedTx, KUSAMA_TEST_OPTIONS);
Expand All @@ -43,7 +43,7 @@ describe('decode', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const decoded = decode(unsigned, KUSAMA_TEST_OPTIONS);

Expand All @@ -56,16 +56,16 @@ describe('decode', () => {
const unsigned = balancesTransfer(
TEST_METHOD_ARGS.balances.transfer,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);
const signingPayload = construct.signingPayload(
unsigned,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
);

const decoded = decode(
signingPayload,
KUSAMA_TEST_OPTIONS
KUSAMA_TEST_OPTIONS,
) as unknown as DecodedSigningPayload;

itDecodesSigningPayloadBalancesTransfer(decoded);
Expand Down
8 changes: 4 additions & 4 deletions packages/txwrapper-core/src/core/decode/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { decodeUnsignedTx } from './decodeUnsignedTx';
*/
export function decode(
unsignedTx: UnsignedTransaction,
options: OptionsWithMeta
options: OptionsWithMeta,
): DecodedUnsignedTx;

/**
Expand All @@ -30,7 +30,7 @@ export function decode(
*/
export function decode(
signedTx: string,
options: OptionsWithMeta
options: OptionsWithMeta,
): DecodedSignedTx;

/**
Expand All @@ -42,12 +42,12 @@ export function decode(
*/
export function decode(
signingPayload: string,
options: OptionsWithMeta
options: OptionsWithMeta,
): DecodedSigningPayload;

export function decode(
data: string | UnsignedTransaction,
options: OptionsWithMeta
options: OptionsWithMeta,
): DecodedSignedTx | DecodedUnsignedTx | DecodedSigningPayload {
if (typeof data === 'string') {
let decodedInfo: DecodedSigningPayload | DecodedSignedTx;
Expand Down
Loading