-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/txwrapper-substrate/src/methods/nominationPools/nominate.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
packages/txwrapper-substrate/src/methods/nominationPools/nominate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters