Skip to content

Commit

Permalink
feat(txwrapper-polkadot): Add crowdloan.addMemo (#99)
Browse files Browse the repository at this point in the history
* feat(txwrapper-polkadot): Add `crowdloan.addMemo`
  • Loading branch information
emostov authored Jun 2, 2021
1 parent f13e3ad commit 0b305ec
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 31 deletions.
24 changes: 24 additions & 0 deletions packages/txwrapper-polkadot/src/methods/crowdloan/addMemo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
itHasCorrectBaseTxInfo,
TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-core';

import {
TEST_METHOD_ARGS,
WESTEND_9030_TEST_OPTIONS,
} from '../../test-helpers';
import { addMemo } from './addMemo';

describe('crowdloan::addMemo', () => {
it('should work', () => {
const unsigned = addMemo(
TEST_METHOD_ARGS.crowdloan.addMemo,
TEST_BASE_TX_INFO,
WESTEND_9030_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);

expect(unsigned.method).toBe('0x40060c00000020ffffffffffffffff');
});
});
30 changes: 30 additions & 0 deletions packages/txwrapper-polkadot/src/methods/crowdloan/addMemo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
Args,
BaseTxInfo,
defineMethod,
OptionsWithMeta,
UnsignedTransaction,
} from '@substrate/txwrapper-core';

export interface CrowdloanAddMemo extends Args {
index: number | string;
memo: string;
}

export function addMemo(
args: CrowdloanAddMemo,
info: BaseTxInfo,
options: OptionsWithMeta
): UnsignedTransaction {
return defineMethod(
{
method: {
args,
name: 'addMemo',
pallet: 'crowdloan',
},
...info,
},
options
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ import {
TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-core';

import { TEST_METHOD_ARGS, WESTEND_50_TEST_OPTIONS } from '../../test-helpers';
import {
TEST_METHOD_ARGS,
WESTEND_9030_TEST_OPTIONS,
} from '../../test-helpers';
import { contribute } from './contribute';

describe('crowdloan::contribute', () => {
it('should work', () => {
const unsigned = contribute(
TEST_METHOD_ARGS.crowdloan.contribute,
TEST_BASE_TX_INFO,
WESTEND_50_TEST_OPTIONS
WESTEND_9030_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);

expect(unsigned.method).toBe(
'0x2a013013f6ffffffffff3f010101ffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
'0x40013013f6ffffffffff3f010101ffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
);
});
});
1 change: 1 addition & 0 deletions packages/txwrapper-polkadot/src/methods/crowdloan/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './addMemo';
export * from './contribute';
export * from './types';
export * from './withdraw';
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ import {
TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-core';

import { TEST_METHOD_ARGS, WESTEND_50_TEST_OPTIONS } from '../../test-helpers';
import {
TEST_METHOD_ARGS,
WESTEND_9030_TEST_OPTIONS,
} from '../../test-helpers';
import { withdraw } from './withdraw';

describe('crowdloan::withdraw', () => {
it('should work', () => {
const unsigned = withdraw(
TEST_METHOD_ARGS.crowdloan.withdraw,
TEST_BASE_TX_INFO,
WESTEND_50_TEST_OPTIONS
WESTEND_9030_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);

expect(unsigned.method).toBe(
'0x2a0290b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe2230'
'0x400290b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe2230'
);
});
});
10 changes: 7 additions & 3 deletions packages/txwrapper-polkadot/src/test-helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getRegistry } from '../index';
import metadataRpc from './westendMetadataRpc50';
import metadataRpc from './westendMetadataRpc9030';

export const WESTEND_50_TEST_OPTIONS = {
export const WESTEND_9030_TEST_OPTIONS = {
metadataRpc,
registry: getRegistry({
specName: 'westend',
chainName: 'Westend',
specVersion: 50,
specVersion: 9030,
metadataRpc,
}),
};
Expand All @@ -27,5 +27,9 @@ export const TEST_METHOD_ARGS = {
index: 12,
who: 'Fr4NzY1udSFFLzb2R3qxVQkwz9cZraWkyfH4h3mVVk7BK7P', // seed "//Charlie"
},
addMemo: {
index: 12,
memo: '0xFFFFFFFFFFFFFFFF',
},
},
};

This file was deleted.

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ __metadata:
languageName: node
linkType: hard

"@substrate/txwrapper-core@^1.1.2, @substrate/txwrapper-core@workspace:packages/txwrapper-core":
"@substrate/txwrapper-core@^1.1.3, @substrate/txwrapper-core@workspace:packages/txwrapper-core":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-core@workspace:packages/txwrapper-core"
dependencies:
Expand All @@ -2491,54 +2491,54 @@ __metadata:
resolution: "@substrate/txwrapper-examples@workspace:packages/txwrapper-examples"
dependencies:
"@polkadot/api": ^4.12.1
"@substrate/txwrapper-polkadot": ^1.1.2
txwrapper-acala: ^1.1.2
"@substrate/txwrapper-polkadot": ^1.1.3
txwrapper-acala: ^1.1.3
languageName: unknown
linkType: soft

"@substrate/txwrapper-orml@^1.1.2, @substrate/txwrapper-orml@workspace:packages/txwrapper-orml":
"@substrate/txwrapper-orml@^1.1.3, @substrate/txwrapper-orml@workspace:packages/txwrapper-orml":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-orml@workspace:packages/txwrapper-orml"
dependencies:
"@acala-network/type-definitions": 0.7.4-1
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
languageName: unknown
linkType: soft

"@substrate/txwrapper-polkadot@^1.1.2, @substrate/txwrapper-polkadot@workspace:packages/txwrapper-polkadot":
"@substrate/txwrapper-polkadot@^1.1.3, @substrate/txwrapper-polkadot@workspace:packages/txwrapper-polkadot":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-polkadot@workspace:packages/txwrapper-polkadot"
dependencies:
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-substrate": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
"@substrate/txwrapper-substrate": ^1.1.3
languageName: unknown
linkType: soft

"@substrate/txwrapper-registry@^1.1.2, @substrate/txwrapper-registry@workspace:packages/txwrapper-registry":
"@substrate/txwrapper-registry@^1.1.3, @substrate/txwrapper-registry@workspace:packages/txwrapper-registry":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-registry@workspace:packages/txwrapper-registry"
dependencies:
"@polkadot/apps-config": ^0.91.2
"@polkadot/networks": ^6.6.1
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
languageName: unknown
linkType: soft

"@substrate/txwrapper-substrate@^1.1.2, @substrate/txwrapper-substrate@workspace:packages/txwrapper-substrate":
"@substrate/txwrapper-substrate@^1.1.3, @substrate/txwrapper-substrate@workspace:packages/txwrapper-substrate":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-substrate@workspace:packages/txwrapper-substrate"
dependencies:
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
languageName: unknown
linkType: soft

"@substrate/txwrapper-template@workspace:packages/txwrapper-template":
version: 0.0.0-use.local
resolution: "@substrate/txwrapper-template@workspace:packages/txwrapper-template"
dependencies:
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-registry": ^1.1.2
"@substrate/txwrapper-substrate": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
"@substrate/txwrapper-registry": ^1.1.3
"@substrate/txwrapper-substrate": ^1.1.3
ts-node: 9.1.1
typescript: 4.1.5
languageName: unknown
Expand Down Expand Up @@ -10873,13 +10873,13 @@ fsevents@^2.1.2:
languageName: node
linkType: hard

"txwrapper-acala@^1.1.2, txwrapper-acala@workspace:packages/txwrapper-acala":
"txwrapper-acala@^1.1.3, txwrapper-acala@workspace:packages/txwrapper-acala":
version: 0.0.0-use.local
resolution: "txwrapper-acala@workspace:packages/txwrapper-acala"
dependencies:
"@acala-network/type-definitions": 0.7.4-1
"@substrate/txwrapper-core": ^1.1.2
"@substrate/txwrapper-orml": ^1.1.2
"@substrate/txwrapper-core": ^1.1.3
"@substrate/txwrapper-orml": ^1.1.3
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 0b305ec

Please sign in to comment.