Skip to content

Commit

Permalink
Add nominate
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Oct 16, 2023
1 parent acb32bc commit 11d4d31
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

import { NominationPoolsCreate } from './create';

export interface NominationPoolscreateWithPoolId extends NominationPoolsCreate {
export interface NominationPoolsCreateWithPoolId extends NominationPoolsCreate {
/**
* A valid PoolId.
*/
Expand All @@ -22,7 +22,7 @@ export interface NominationPoolscreateWithPoolId extends NominationPoolsCreate {
* @param options - Registry and metadata used for constructing the method.
*/
export function createWithPoolId(
args: NominationPoolsCreate,
args: NominationPoolsCreateWithPoolId,
info: BaseTxInfo,
options: OptionsWithMeta
): UnsignedTransaction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './claimPayout';
export * from './create';
export * from './createWithPoolId';
export * from './join';
export * from './nominate';
export * from './poolWithdrawUnbonded';
export * from './unbond';
export * from './withdrawUnbonded';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
itHasCorrectBaseTxInfo,
KUSAMA_TEST_OPTIONS,
TEST_BASE_TX_INFO,
} from '@substrate/txwrapper-dev';

import { TEST_METHOD_ARGS } from '../../test-helpers';
import { nominate } from './nominate';

describe('nominationPools::nominate', () => {
it('should work', () => {
const unsigned = nominate(
TEST_METHOD_ARGS.nominationPools.nominate,
TEST_BASE_TX_INFO,
KUSAMA_TEST_OPTIONS
);

itHasCorrectBaseTxInfo(unsigned);

expect(unsigned.method).toBe(
'0x29080400000008d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48'
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
Args,
BaseTxInfo,
defineMethod,
OptionsWithMeta,
UnsignedTransaction,
} from '@substrate/txwrapper-core';

export interface NominationPoolsNominate extends Args {
/**
* A valid PoolId.
*/
poolId: number | string;
/**
* Array of validators.
*/
validators: Array<string>;
}

/**
* Nominate on behalf of the pool.
*
* The dispatch origin of this call must be signed by the pool nominator or the pool
* root role.
*
* This directly forward the call to the staking pallet, on behalf of the pool bonded
* account.
*
* @param args - Arguments specific to this method.
* @param info - Information required to construct the transaction.
* @param options - Registry and metadata used for constructing the method.
*/
export function nominate(
args: NominationPoolsNominate,
info: BaseTxInfo,
options: OptionsWithMeta
): UnsignedTransaction {
return defineMethod(
{
method: {
args,
name: 'nominate',
pallet: 'nominationPools',
},
...info,
},
options
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ export const TEST_METHOD_ARGS = {
memberAccount: '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5',
unbondingPoints: '10000000',
},
nominate: {
poolId: 4,
validators: [
'15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5',
'14E5nqKAp3oAJcmzgZhUD2RcptBeUBScxKHgJKU4HPNcKVf3',
],
},
poolWithdrawUnbonded: {
poolId: 1,
numSlashingSpans: 2,
Expand Down

0 comments on commit 11d4d31

Please sign in to comment.